/** * @see AStarHeuristic#getCost(TileBasedMap, Mover, int, int, int, int) */ public float getCost(TileBasedMap map, Mover mover, int x, int y, int tx, int ty) { float dx = tx - x; float dy = ty - y; return ((dx*dx)+(dy*dy)); }
/** * @see AStarHeuristic#getCost(TileBasedMap, Mover, int, int, int, int) */ public float getCost(TileBasedMap map, Mover mover, int x, int y, int tx, int ty) { float dx = tx - x; float dy = ty - y; float result = (float) (Math.sqrt((dx*dx)+(dy*dy))); return result; }
/** * @see TileBasedMap#blocked(Mover, int, int) */ public boolean blocked(Mover mover, int x, int y) { // if there's a unit at the location, then it's blocked if (getUnit(x,y) != 0) { return true; } int unit = ((RoverMover) mover).getType(); // Either it's blocked or its not, simpler return terrain[x][y] == BLOCKED; }
/** * @see org.newdawn.slick.util.pathfinding.TileBasedMap#blocked(org.newdawn.slick.util.pathfinding.Mover, int, int) */ public boolean blocked(Mover mover, int x, int y) { // if theres a unit at the location, then it's blocked if (getUnit(x,y) != 0) { return true; } int unit = ((RoverMover) mover).getType(); // Either it's blocked or its not, simpler return terrain[x][y] == BLOCKED; }
@Override public float getCost(TileBasedMap ctx, Mover mover, int x, int y, int goalX, int goalY) { return Math.max(Math.abs(x - goalX), Math.abs(y - goalY)); /* float diagonal = Math.min(Math.abs(x - goalX), Math.abs(y - goalY)); float straight = (Math.abs(x - goalX) + Math.abs(y - goalY)); float h = (DIAGONAL_COST * diagonal) + (ADJACENT_COST * (straight - (2f * diagonal))); return h;*/ }
public Mover getMover() { return null; }
/** * @see AStarHeuristic#getCost(TileBasedMap, Mover, int, int, int, int) */ public float getCost(TileBasedMap map, Mover mover, int x, int y, int tx, int ty) { return minimumCost * (Math.abs(x-tx) + Math.abs(y-ty)); }
/** * @see TileBasedMap#getCost(Mover, int, int, int, int) */ public float getCost(Mover mover, int sx, int sy, int tx, int ty) { return 1; }
/** * @see org.newdawn.slick.util.pathfinding.TileBasedMap#getCost(Mover, int, int, int, int) */ public float getCost(Mover mover, int sx, int sy, int tx, int ty) { return 1; }
@Override public float getCost(TileBasedMap ctx, Mover mover, int x, int y, int goalX, int goalY) { return Math.max(Math.abs(x - goalX), Math.abs(y - goalY)); }
/** * Path finding context implementation * * @return The current mover */ public Mover getMover() { return null; }