If the player location is not known yet during sort, find it. This only happens when the loop has not been run yet.
Signed-off-by: Chris Cromer <chris@cromer.cl>
This commit is contained in:
parent
cb7fe3767d
commit
5510f132b7
@ -69,7 +69,7 @@ public interface Constants {
|
|||||||
/**
|
/**
|
||||||
* The amount of chests to draw, if less then 2 the game cannot be won
|
* The amount of chests to draw, if less then 2 the game cannot be won
|
||||||
*/
|
*/
|
||||||
int CHESTS = 2;
|
int CHESTS = 3;
|
||||||
/**
|
/**
|
||||||
* The amount of enemies to draw
|
* The amount of enemies to draw
|
||||||
*/
|
*/
|
||||||
|
@ -107,8 +107,11 @@ public interface PlayerAI extends Runnable, Constants {
|
|||||||
return Double.compare(state1Distance, state2Distance);
|
return Double.compare(state1Distance, state2Distance);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// We don't know where the player is, so equal importance
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//scene.getCanvas().getEnemies();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return destinations;
|
return destinations;
|
||||||
|
@ -447,6 +447,9 @@ public class PlayerAStarAI extends AI implements PlayerAI, Constants {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void sortDestinations() {
|
public void sortDestinations() {
|
||||||
|
if (initial == null) {
|
||||||
|
initial = new State(player.getCell().getX(), player.getCell().getY(), State.Type.PLAYER, null, 0);
|
||||||
|
}
|
||||||
destinations = sortDestinations(destinations, initial);
|
destinations = sortDestinations(destinations, initial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,6 +242,9 @@ public class PlayerBreadthFirstAI extends AI implements PlayerAI, Constants {
|
|||||||
* Sort the destinations by importance, if the importance is the same then sort them by distance
|
* Sort the destinations by importance, if the importance is the same then sort them by distance
|
||||||
*/
|
*/
|
||||||
public void sortDestinations() {
|
public void sortDestinations() {
|
||||||
|
if (initial == null) {
|
||||||
|
initial = new State(player.getCell().getX(), player.getCell().getY(), State.Type.PLAYER, null, 0);
|
||||||
|
}
|
||||||
destinations = sortDestinations(destinations, initial);
|
destinations = sortDestinations(destinations, initial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user