|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.generation5.ai.AStarPathfinder
Implements the A* algorithm. Pathing can be done on any class that implements the
Navigable interface.
Navigable| Nested Class Summary | |
static class |
AStarPathfinder.AStarNode
The pathfinder node. |
| Nested classes inherited from class org.generation5.ai.Pathfinder |
Pathfinder.Node |
| Field Summary | |
static int |
IN_PROGRESS
Returned by getStatus if the pathfinder is still running. |
protected java.util.LinkedList |
listClosed
The closed list. |
protected java.util.LinkedList |
listOpen
The open list. |
protected Navigable |
navMap
The current navigable environment. |
protected AStarPathfinder.AStarNode |
nodeBest
The current best node. |
protected AStarPathfinder.AStarNode |
nodeGoal
The goal node. |
protected AStarPathfinder.AStarNode |
nodeStart
The start node. |
static int |
PATH_FOUND
Returned by getStatus if a path has been found. |
static int |
PATH_NOT_FOUND
Returned by getStatus if a path cannot be found. |
protected int |
pathStatus
The current status of the pathfinder. |
| Constructor Summary | |
AStarPathfinder()
Creates a new instance of AStarPathfinder |
|
| Method Summary | |
protected void |
addToOpen(AStarPathfinder.AStarNode node)
Add the new child to the open list, ordering by the f-value. |
protected AStarPathfinder.AStarNode |
checkClosed(AStarPathfinder.AStarNode node)
Check the closed list for the given node. |
protected AStarPathfinder.AStarNode |
checkOpen(AStarPathfinder.AStarNode node)
Check the open list for a given node. |
protected void |
createChildren(AStarPathfinder.AStarNode node)
Create the children surrounding the current best node. |
void |
doStep()
Iterate the pathfinder through one step. |
protected AStarPathfinder.AStarNode |
getBest()
Assigns the best node from the open list. |
AStarPathfinder.AStarNode |
getBestNode()
Returns the current best node. |
java.util.LinkedList |
getClosed()
Return the closed list. |
AStarPathfinder.AStarNode |
getGoal()
Returns the goal node. |
java.util.LinkedList |
getOpen()
Return the open list. |
AStarPathfinder.AStarNode |
getStart()
Returns the start node. |
int |
getStatus()
Return the current status of the pathfinder. |
void |
init()
Initialize the pathfinder. |
protected void |
linkChild(AStarPathfinder.AStarNode node,
int x,
int y)
Link the children to the parent node. |
void |
reset()
Reset the pathfinder (just calls init). |
void |
setEndpoints(AStarPathfinder.AStarNode start,
AStarPathfinder.AStarNode goal)
Set the starting and goal points for the pathfinder. |
void |
setEndpoints(int sx,
int sy,
int gx,
int gy)
Sets the starting and goal points for the pathfinder. |
void |
setGoal(AStarPathfinder.AStarNode goal)
Set the goal node. |
void |
setNavigable(Navigable map)
Sets the navigable to use in the pathfinder. |
void |
setStart(AStarPathfinder.AStarNode start)
Set the start node. |
protected void |
updateParents(AStarPathfinder.AStarNode node)
Update the parents for the new route. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int PATH_NOT_FOUND
getStatus if a path cannot be found.
getStatus(),
Constant Field Valuespublic static final int PATH_FOUND
getStatus if a path has been found.
getStatus(),
Constant Field Valuespublic static final int IN_PROGRESS
getStatus if the pathfinder is still running.
getStatus(),
Constant Field Valuesprotected int pathStatus
PATH_FOUND,
PATH_NOT_FOUND,
IN_PROGRESSprotected java.util.LinkedList listOpen
protected java.util.LinkedList listClosed
protected AStarPathfinder.AStarNode nodeGoal
protected AStarPathfinder.AStarNode nodeStart
protected AStarPathfinder.AStarNode nodeBest
doStep.
protected Navigable navMap
| Constructor Detail |
public AStarPathfinder()
| Method Detail |
public int getStatus()
pathStatuspublic void doStep()
doStep in interface Steppablepublic void init()
init in interface Steppablepublic void reset()
init).
reset in interface Steppablepublic void setNavigable(Navigable map)
Navigable interface.
map - the map (or other Navigable object) to find a path through.
public void setEndpoints(int sx,
int sy,
int gx,
int gy)
sx - the start x-position.sy - the start y-position.gx - the goal x-position.gy - the goal y-position.
public void setEndpoints(AStarPathfinder.AStarNode start,
AStarPathfinder.AStarNode goal)
AStarNode's x and y variables, the pathfinder sets all
the other necessary node parameters.
start - the start node.goal - the goal node.public AStarPathfinder.AStarNode getStart()
public void setStart(AStarPathfinder.AStarNode start)
start - the start node.public void setGoal(AStarPathfinder.AStarNode goal)
goal - the goal node.public AStarPathfinder.AStarNode getGoal()
protected AStarPathfinder.AStarNode getBest()
public AStarPathfinder.AStarNode getBestNode()
protected void createChildren(AStarPathfinder.AStarNode node)
node - the node to create the children from.
protected void linkChild(AStarPathfinder.AStarNode node,
int x,
int y)
node - the parent node.x - the x-position of the new child.y - the y-position of the new child.protected void addToOpen(AStarPathfinder.AStarNode node)
node - the node to add to the open list.protected void updateParents(AStarPathfinder.AStarNode node)
node - the root node.protected AStarPathfinder.AStarNode checkOpen(AStarPathfinder.AStarNode node)
node - the node to check for.
protected AStarPathfinder.AStarNode checkClosed(AStarPathfinder.AStarNode node)
node - the node to check for.
public java.util.LinkedList getOpen()
public java.util.LinkedList getClosed()
|
This documentation is part of the Generation5 JDK.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||