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
-
Field Summary
Modifier and TypeFieldDescriptionprotected Pathfinder.TreeNode
The goal node.static int
Returned bygetStatus
if the pathfinder is still running.static int
Returned bygetStatus
if a path has been found.static int
Returned bygetStatus
if a path cannot be found.protected Pathfinder.TreeNode
The start node.protected static double
Node weight bonus for nodes that do not change the walking direction. -
Constructor Summary
ModifierConstructorDescriptionprotected
Pathfinder(int startX, int startY, Rectangle2D destination, double maxDist)
-
Method Summary
Modifier and TypeMethodDescriptionabstract Pathfinder.TreeNode
createNode(int x, int y)
Create a new TreeNodegetPath()
protected int
Return the current status of the pathfinder.protected void
init()
Initialization that can not be done safely in the constructor.protected boolean
Checks if the goal is unreachable.
-
Field Details
-
PATH_NOT_FOUND
public static final int PATH_NOT_FOUNDReturned bygetStatus
if a path cannot be found.- See Also:
getStatus()
, Constant Field Values
-
PATH_FOUND
public static final int PATH_FOUNDReturned bygetStatus
if a path has been found.- See Also:
getStatus()
, Constant Field Values
-
IN_PROGRESS
public static final int IN_PROGRESSReturned bygetStatus
if the pathfinder is still running.- See Also:
getStatus()
, Constant Field Values
-
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:
- Constant Field Values
-
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
-