Fixed Astar algo
This commit is contained in:
parent
5e17bdd5e5
commit
f7c3a895f0
2 changed files with 2 additions and 4 deletions
|
|
@ -32,8 +32,6 @@ public class AStar{
|
||||||
|
|
||||||
protected void initializePathfinder() {
|
protected void initializePathfinder() {
|
||||||
System.out.println("Initializing pathfinder");
|
System.out.println("Initializing pathfinder");
|
||||||
|
|
||||||
AStarNode2D.heuristic = Heuristic.Euclidean;
|
|
||||||
|
|
||||||
// Create the pathfinder.
|
// Create the pathfinder.
|
||||||
pathfinder = new AStarPathfinder();
|
pathfinder = new AStarPathfinder();
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import ei.game.algo.AStarNeighbour.Location;
|
||||||
*/
|
*/
|
||||||
public class AStarNode2D extends AStarNode {
|
public class AStarNode2D extends AStarNode {
|
||||||
protected final static float adjacentCost = 1;
|
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);
|
protected final static float tieBreaker = adjacentCost/(1024f/1024f);
|
||||||
|
|
||||||
public enum Heuristic {
|
public enum Heuristic {
|
||||||
|
|
@ -20,7 +20,7 @@ public class AStarNode2D extends AStarNode {
|
||||||
DiagonalWithTieBreakingCrossProduct,
|
DiagonalWithTieBreakingCrossProduct,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Heuristic heuristic = Heuristic.Manhattan;
|
public static Heuristic heuristic = Heuristic.Euclidean;
|
||||||
|
|
||||||
protected int x, y;
|
protected int x, y;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue