Skip to content

Commit

Permalink
A* bugfixc
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Apr 27, 2019
1 parent 8911546 commit 77cdcf0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/java/net/citizensnpcs/api/astar/SimpleAStarStorage.java
Expand Up @@ -15,7 +15,7 @@ public class SimpleAStarStorage implements AStarStorage {
@Override
public void close(AStarNode node) {
open.remove(node);
closed.put(node, node.f);
closed.put(node, node.g);
}

@Override
Expand All @@ -26,7 +26,7 @@ public AStarNode getBestNode() {
@Override
public void open(AStarNode node) {
queue.offer(node);
open.put(node, node.f);
open.put(node, node.g);
closed.remove(node);
}

Expand All @@ -37,17 +37,17 @@ public AStarNode removeBestNode() {

@Override
public boolean shouldExamine(AStarNode neighbour) {
Float openF = open.get(neighbour);
if (openF != null && openF > neighbour.f) {
Float openG = open.get(neighbour);
if (openG != null && openG > neighbour.g) {
open.remove(neighbour);
openF = null;
openG = null;
}
Float closedF = closed.get(neighbour);
if (closedF != null && closedF > neighbour.f) {
Float closedG = closed.get(neighbour);
if (closedG != null && closedG > neighbour.g) {
closed.remove(neighbour);
closedF = null;
closedG = null;
}
return closedF == null && openF == null;
return closedG == null && openG == null;
}

@Override
Expand Down

0 comments on commit 77cdcf0

Please sign in to comment.