Class Pathfinder

java.lang.Object
games.stendhal.server.core.pathfinder.Pathfinder
Direct Known Subclasses:
SimplePathfinder

public abstract class Pathfinder extends Object
Implements the A* algorithm. Pathing can be done on any class that implements the Navigable interface. See org.generation5.ai.Navigable.
Author:
James Matthews
  • Field Details

    • PATH_NOT_FOUND

      public static final int PATH_NOT_FOUND
      Returned by getStatus if a path cannot be found.
      See Also:
      getStatus(), Constant Field Values
    • PATH_FOUND

      public static final int PATH_FOUND
      Returned by getStatus if a path has been found.
      See Also:
      getStatus(), Constant Field Values
    • IN_PROGRESS

      public static final int IN_PROGRESS
      Returned by getStatus if the pathfinder is still running.
      See Also:
      getStatus(), Constant Field Values
    • STRAIGHT_PATH_PREFERENCE_FACTOR

      protected static final double STRAIGHT_PATH_PREFERENCE_FACTOR
      Node weight bonus for nodes that do not change the walking direction.
      See Also:
      Constant Field Values
    • goalNode

      protected Pathfinder.TreeNode goalNode
      The goal node.
    • startNode

      protected Pathfinder.TreeNode startNode
      The start node.
  • Constructor Details

    • Pathfinder

      protected Pathfinder(int startX, int startY, Rectangle2D destination, double maxDist)
  • 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

      public final List<Node> 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

      public abstract Pathfinder.TreeNode createNode(int x, int y)
      Create a new TreeNode
      Parameters:
      x - x coordinate of the node
      y - y coordinate of the node
      Returns:
      TreeNode