Browse Source

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>
master
Chris Cromer 2 years ago
parent
commit
5510f132b7
  1. 2
      src/main/java/cl/cromer/azaraka/Constants.java
  2. 3
      src/main/java/cl/cromer/azaraka/ai/PlayerAI.java
  3. 3
      src/main/java/cl/cromer/azaraka/ai/PlayerAStarAI.java
  4. 3
      src/main/java/cl/cromer/azaraka/ai/PlayerBreadthFirstAI.java

2
src/main/java/cl/cromer/azaraka/Constants.java

@ -69,7 +69,7 @@ public interface Constants {
/**
* 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
*/

3
src/main/java/cl/cromer/azaraka/ai/PlayerAI.java

@ -107,8 +107,11 @@ public interface PlayerAI extends Runnable, Constants {
return Double.compare(state1Distance, state2Distance);
}
else {
// We don't know where the player is, so equal importance
return 0;
}
//scene.getCanvas().getEnemies();
}
});
return destinations;

3
src/main/java/cl/cromer/azaraka/ai/PlayerAStarAI.java

@ -447,6 +447,9 @@ public class PlayerAStarAI extends AI implements PlayerAI, Constants {
*/
@Override
public void sortDestinations() {
if (initial == null) {
initial = new State(player.getCell().getX(), player.getCell().getY(), State.Type.PLAYER, null, 0);
}
destinations = sortDestinations(destinations, initial);
}

3
src/main/java/cl/cromer/azaraka/ai/PlayerBreadthFirstAI.java

@ -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
*/
public void sortDestinations() {
if (initial == null) {
initial = new State(player.getCell().getX(), player.getCell().getY(), State.Type.PLAYER, null, 0);
}
destinations = sortDestinations(destinations, initial);
}

Loading…
Cancel
Save