Fix infinite search in A* Search
Signed-off-by: Chris Cromer <chris@cromer.cl>
This commit is contained in:
parent
7744b5ae6d
commit
6183bf84c6
@ -95,7 +95,7 @@ public class PlayerAStarAI extends AI implements PlayerAI, Constants {
|
|||||||
cameFrom.put(start, start);
|
cameFrom.put(start, start);
|
||||||
costSoFar.put(start, 0.0);
|
costSoFar.put(start, 0.0);
|
||||||
|
|
||||||
while (frontier.size() > 0) {
|
while (frontier.size() > 0 && cameFrom.size() <= (HORIZONTAL_CELLS * VERTICAL_CELLS) * 2) {
|
||||||
State current = frontier.poll();
|
State current = frontier.poll();
|
||||||
|
|
||||||
if (current.equals(goal)) {
|
if (current.equals(goal)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user