Class AStarPathfinder
java.lang.Object
de.bsommerfeld.pathetic.engine.pathfinder.AbstractPathfinder
de.bsommerfeld.pathetic.engine.pathfinder.AStarPathfinder
- All Implemented Interfaces:
Pathfinder
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.
-
Field Summary
Fields inherited from class de.bsommerfeld.pathetic.engine.pathfinder.AbstractPathfinder
EMPTY_PATH_POSITIONS, navigationPointProvider, nodeCostProcessors, nodeValidationProcessors, offsets, pathfinderConfiguration -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidPrepares the algorithm-specific initial setup required before executing the pathfinding logic.protected voidmarkNodeAsExpanded(Node node) Marks the given node as expanded (i.e., added to the "closed set").protected voidAbstract method for algorithm-specific cleanup, called after pathfinding execution.protected voidprocessSuccessors(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.Methods inherited from class de.bsommerfeld.pathetic.engine.pathfinder.AbstractPathfinder
abort, createStartNode, findPath, reconstructPath, registerPathfindingHookMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.bsommerfeld.pathetic.api.pathing.Pathfinder
findPath
-
Constructor Details
-
AStarPathfinder
-
-
Method Details
-
initializeSearch
protected void initializeSearch()Description copied from class:AbstractPathfinderPrepares 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:
initializeSearchin classAbstractPathfinder
-
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:
processSuccessorsin classAbstractPathfinder- 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
Description copied from class:AbstractPathfinderMarks 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:
markNodeAsExpandedin classAbstractPathfinder- Parameters:
node- The node that has been taken from the open set and is being expanded.
-
performAlgorithmCleanup
protected void performAlgorithmCleanup()Description copied from class:AbstractPathfinderAbstract method for algorithm-specific cleanup, called after pathfinding execution. To be implemented by subclasses likeAStarPathfinder.- Specified by:
performAlgorithmCleanupin classAbstractPathfinder
-