Fixed Astar algo

This commit is contained in:
Ziver Koc 2007-04-17 11:40:49 +00:00
parent 5e17bdd5e5
commit f7c3a895f0
2 changed files with 2 additions and 4 deletions

View file

@ -32,8 +32,6 @@ public class AStar{
protected void initializePathfinder() {
System.out.println("Initializing pathfinder");
AStarNode2D.heuristic = Heuristic.Euclidean;
// Create the pathfinder.
pathfinder = new AStarPathfinder();

View file

@ -9,7 +9,7 @@ import ei.game.algo.AStarNeighbour.Location;
*/
public class AStarNode2D extends AStarNode {
protected final static float adjacentCost = 1;
protected final static float diagonalCost = (float)Math.sqrt(2)*adjacentCost;
protected final static float diagonalCost = (float)Math.sqrt(2)*adjacentCost+1;
protected final static float tieBreaker = adjacentCost/(1024f/1024f);
public enum Heuristic {
@ -20,7 +20,7 @@ public class AStarNode2D extends AStarNode {
DiagonalWithTieBreakingCrossProduct,
}
public static Heuristic heuristic = Heuristic.Manhattan;
public static Heuristic heuristic = Heuristic.Euclidean;
protected int x, y;