Class Pathfinder
java.lang.Object
games.stendhal.server.core.pathfinder.Pathfinder
- Direct Known Subclasses:
SimplePathfinder
Implements the A* algorithm. Pathing can be done on any class that implements
the
Navigable interface. See org.generation5.ai.Navigable.- Author:
- James Matthews
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Pathfinder.TreeNodeThe goal node.static final intReturned bygetStatusif the pathfinder is still running.static final intReturned bygetStatusif a path has been found.static final intReturned bygetStatusif a path cannot be found.protected Pathfinder.TreeNodeThe start node.protected static final doubleNode weight bonus for nodes that do not change the walking direction. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPathfinder(int startX, int startY, Rectangle2D destination, double maxDist) -
Method Summary
Modifier and TypeMethodDescriptionabstract Pathfinder.TreeNodecreateNode(int x, int y) Create a new TreeNodegetPath()protected intReturn the current status of the pathfinder.protected voidinit()Initialization that can not be done safely in the constructor.protected booleanChecks if the goal is unreachable.
-
Field Details
-
PATH_NOT_FOUND
public static final int PATH_NOT_FOUNDReturned bygetStatusif a path cannot be found.- See Also:
-
PATH_FOUND
public static final int PATH_FOUNDReturned bygetStatusif a path has been found.- See Also:
-
IN_PROGRESS
public static final int IN_PROGRESSReturned bygetStatusif the pathfinder is still running.- See Also:
-
STRAIGHT_PATH_PREFERENCE_FACTOR
protected static final double STRAIGHT_PATH_PREFERENCE_FACTORNode weight bonus for nodes that do not change the walking direction.- See Also:
-
goalNode
The goal node. -
startNode
The start node.
-
-
Constructor Details
-
Pathfinder
-
-
Method Details
-
init
protected void init()Initialization that can not be done safely in the constructor. -
getStatus
protected int getStatus()Return the current status of the pathfinder.- Returns:
- the pathfinder status.
- See Also:
-
pathStatus
-
getPath
-
unreachableGoal
protected boolean unreachableGoal()Checks if the goal is unreachable. Only the outer nodes of the goal are checked. There could be other reasons, why a goal is unreachable.- Returns:
- true checks if the goal is unreachable
-
createNode
Create a new TreeNode- Parameters:
x- x coordinate of the nodey- y coordinate of the node- Returns:
- TreeNode
-