|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface AStarGoal
This class defines the goal of A* algorithm, it affects how the A* works. When implementing this class you may a few several things. 1) extra cost for edges between two nodes 2) wether A* may use the node (this is useful when you want to forbig some nodes / states) 3) heuristic function which estimates the distance from node to the goal node !NOTE! That this heuristic must be correct for A* to work correctly, that means the returned distance must be smaller or equal to the real distance. (In 2D, 3D a euklidian metric will do the job). Open and Close list will also be stored in this class - that's because after the A* finish the job you might be interested what's inside them. When you providing a AStarGoal to a AStar.aStar() be sure that AStarOpenList and AStarCloseList is empty!
Method Summary | |
---|---|
int |
getEstimatedDistanceToGoal(java.lang.Object node)
This is heuristic function. ! |
int |
getExtraCost(java.lang.Object nodeFrom,
java.lang.Object nodeTo)
Returns extra cost to add to value when trying to go nodeFrom to nodeTo ... of course it can depends only on nodeTo (some special kind of a floor for instance) Don't worry about the edge cost to become negative, A* ensures that that the least cost is 0 (Algorithm can't work over graphs with negative costs.) |
boolean |
isGoalReached(java.lang.Object actualNode)
Returns true, if we've reached the goal ... e.g. actualNode is node we were trying to get to if this function never returns true, A* will run until all nodes are evaluated |
boolean |
isNodeOpened(java.lang.Object node)
Returns true if A* can use this node (e.g. to step on this type of floor) You can use it to forbid some specific nodes |
void |
setCloseList(java.util.Collection closeList)
This is called at the beggining of the A* algorithm to bind the close list to the goal (you may use it check which nodes we've visited, etc... for extra cost for instance). |
void |
setOpenList(java.util.Collection openList)
This is called at the beggining of the A* algorithm to bind the open list to the goal (you may use it check which nodes we've visited, etc... for extra cost for instance). |
Method Detail |
---|
void setOpenList(java.util.Collection openList)
void setCloseList(java.util.Collection closeList)
int getEstimatedDistanceToGoal(java.lang.Object node)
boolean isNodeOpened(java.lang.Object node)
int getExtraCost(java.lang.Object nodeFrom, java.lang.Object nodeTo)
boolean isGoalReached(java.lang.Object actualNode)
actualNode
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |