Class AStarPathfinder

java.lang.Object
de.bsommerfeld.pathetic.engine.pathfinder.AbstractPathfinder
de.bsommerfeld.pathetic.engine.pathfinder.AStarPathfinder
All Implemented Interfaces:
Pathfinder

public final class AStarPathfinder extends AbstractPathfinder
An A* pathfinding algorithm that uses a heuristic to guide the search toward the target. It balances the actual cost from the start (G-cost) with the estimated cost to the target (H-cost).

This implementation uses:

  • A Fibonacci heap for the open set (priority queue).
  • Addressable heap handles for efficient G-cost updates (decrease-key).
  • A grid-based closed set with Bloom filters (GridRegionData) to quickly check expanded nodes.

Thread-safety: Each pathfinding operation gets its own AStarPathfinder.PathfindingSession, ensuring thread-safety for concurrent requests.

  • Constructor Details

  • Method Details

    • initializeSearch

      protected void initializeSearch()
      Description copied from class: AbstractPathfinder
      Prepares the algorithm-specific initial setup required before executing the pathfinding logic. This method is designed to be overridden by subclasses to implement their respective initialization logic, such as setting up data structures, precomputing values, or resetting internal state. It is called at the beginning of a pathfinding request.
      Specified by:
      initializeSearch in class AbstractPathfinder
    • processSuccessors

      protected void processSuccessors(PathPosition start, PathPosition target, Node currentNode, org.jheaps.tree.FibonacciHeap<Double,Node> openSet, SearchContext searchContext)
      Processes the successors of the current node, checking if they're in the open or closed set, calculating costs, validating traversability, and updating the open set as needed.
      Specified by:
      processSuccessors in class AbstractPathfinder
      Parameters:
      start - The starting position of the pathfinding request.
      target - The target position of the pathfinding request.
      currentNode - The node being expanded.
      openSet - The priority queue (Fibonacci heap) holding nodes to explore.
      searchContext - The context for the current search.
    • markNodeAsExpanded

      protected void markNodeAsExpanded(Node node)
      Description copied from class: AbstractPathfinder
      Marks the given node as expanded (i.e., added to the "closed set"). Subclasses should implement this to update their specific closed set mechanism.
      Specified by:
      markNodeAsExpanded in class AbstractPathfinder
      Parameters:
      node - The node that has been taken from the open set and is being expanded.
    • performAlgorithmCleanup

      protected void performAlgorithmCleanup()
      Description copied from class: AbstractPathfinder
      Abstract method for algorithm-specific cleanup, called after pathfinding execution. To be implemented by subclasses like AStarPathfinder.
      Specified by:
      performAlgorithmCleanup in class AbstractPathfinder