|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.newdawn.slick.util.pathfinding.AStarPathFinder
public class AStarPathFinder
A path finder implementation that uses the AStar heuristic based algorithm to determine a path.
| Constructor Summary | |
|---|---|
AStarPathFinder(TileBasedMap map,
int maxSearchDistance,
boolean allowDiagMovement)
Create a path finder with the default heuristic - closest to target. |
|
AStarPathFinder(TileBasedMap map,
int maxSearchDistance,
boolean allowDiagMovement,
AStarHeuristic heuristic)
Create a path finder |
|
| Method Summary | |
|---|---|
protected void |
addToClosed(org.newdawn.slick.util.pathfinding.AStarPathFinder.Node node)
Add a node to the closed list |
protected void |
addToOpen(org.newdawn.slick.util.pathfinding.AStarPathFinder.Node node)
Add a node to the open list |
Path |
findPath(Mover mover,
int sx,
int sy,
int tx,
int ty)
Find a path from the starting location provided (sx,sy) to the target location (tx,ty) avoiding blockages and attempting to honour costs provided by the tile map. |
int |
getCurrentX()
Get the X coordinate of the node currently being evaluated |
int |
getCurrentY()
Get the Y coordinate of the node currently being evaluated |
protected org.newdawn.slick.util.pathfinding.AStarPathFinder.Node |
getFirstInOpen()
Get the first element from the open list. |
float |
getHeuristicCost(Mover mover,
int x,
int y,
int tx,
int ty)
Get the heuristic cost for the given location. |
float |
getMovementCost(Mover mover,
int sx,
int sy,
int tx,
int ty)
Get the cost to move through a given location |
Mover |
getMover()
Get the object being moved along the path if any |
int |
getSearchDistance()
Get the distance that has been searched to reach this point |
int |
getSourceX()
Get the x coordinate of the source location |
int |
getSourceY()
Get the y coordinate of the source location |
protected boolean |
inClosedList(org.newdawn.slick.util.pathfinding.AStarPathFinder.Node node)
Check if the node supplied is in the closed list |
protected boolean |
inOpenList(org.newdawn.slick.util.pathfinding.AStarPathFinder.Node node)
Check if a node is in the open list |
protected boolean |
isValidLocation(Mover mover,
int sx,
int sy,
int x,
int y)
Check if a given location is valid for the supplied mover |
protected void |
removeFromClosed(org.newdawn.slick.util.pathfinding.AStarPathFinder.Node node)
Remove a node from the closed list |
protected void |
removeFromOpen(org.newdawn.slick.util.pathfinding.AStarPathFinder.Node node)
Remove a node from the open list |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AStarPathFinder(TileBasedMap map,
int maxSearchDistance,
boolean allowDiagMovement)
map - The map to be searchedmaxSearchDistance - The maximum depth we'll search before giving upallowDiagMovement - True if the search should try diaganol movement
public AStarPathFinder(TileBasedMap map,
int maxSearchDistance,
boolean allowDiagMovement,
AStarHeuristic heuristic)
heuristic - The heuristic used to determine the search order of the mapmap - The map to be searchedmaxSearchDistance - The maximum depth we'll search before giving upallowDiagMovement - True if the search should try diaganol movement| Method Detail |
|---|
public Path findPath(Mover mover,
int sx,
int sy,
int tx,
int ty)
PathFinder
findPath in interface PathFindermover - The entity that will be moving along the path. This provides
a place to pass context information about the game entity doing the moving, e.g.
can it fly? can it swim etc.sx - The x coordinate of the start locationsy - The y coordinate of the start locationtx - The x coordinate of the target locationty - Teh y coordinate of the target location
PathFinder.findPath(Mover, int, int, int, int)public int getCurrentX()
public int getCurrentY()
protected org.newdawn.slick.util.pathfinding.AStarPathFinder.Node getFirstInOpen()
protected void addToOpen(org.newdawn.slick.util.pathfinding.AStarPathFinder.Node node)
node - The node to be added to the open listprotected boolean inOpenList(org.newdawn.slick.util.pathfinding.AStarPathFinder.Node node)
node - The node to check for
protected void removeFromOpen(org.newdawn.slick.util.pathfinding.AStarPathFinder.Node node)
node - The node to remove from the open listprotected void addToClosed(org.newdawn.slick.util.pathfinding.AStarPathFinder.Node node)
node - The node to add to the closed listprotected boolean inClosedList(org.newdawn.slick.util.pathfinding.AStarPathFinder.Node node)
node - The node to search for
protected void removeFromClosed(org.newdawn.slick.util.pathfinding.AStarPathFinder.Node node)
node - The node to remove from the closed list
protected boolean isValidLocation(Mover mover,
int sx,
int sy,
int x,
int y)
mover - The mover that would hold a given locationsx - The starting x coordinatesy - The starting y coordinatex - The x coordinate of the location to checky - The y coordinate of the location to check
public float getMovementCost(Mover mover,
int sx,
int sy,
int tx,
int ty)
mover - The entity that is being movedsx - The x coordinate of the tile whose cost is being determinedsy - The y coordiante of the tile whose cost is being determinedtx - The x coordinate of the target locationty - The y coordinate of the target location
public float getHeuristicCost(Mover mover,
int x,
int y,
int tx,
int ty)
mover - The entity that is being movedx - The x coordinate of the tile whose cost is being determinedy - The y coordiante of the tile whose cost is being determinedtx - The x coordinate of the target locationty - The y coordinate of the target location
public Mover getMover()
PathFindingContext
getMover in interface PathFindingContextPathFindingContext.getMover()public int getSearchDistance()
PathFindingContext
getSearchDistance in interface PathFindingContextPathFindingContext.getSearchDistance()public int getSourceX()
PathFindingContext
getSourceX in interface PathFindingContextPathFindingContext.getSourceX()public int getSourceY()
PathFindingContext
getSourceY in interface PathFindingContextPathFindingContext.getSourceY()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||