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 primitive min-heap for the open set (priority queue).
- Addressable heap handles for efficient G-cost updates (decrease-key).
- A spatial closed set with Bloom filters (
SpatialData) to quickly check expanded nodes.
Thread-safety: Each pathfinding operation gets its own PathfindingSession, ensuring
thread-safety for concurrent requests.
-
Field Summary
Fields inherited from class de.bsommerfeld.pathetic.engine.pathfinder.AbstractPathfinder
costProcessors, EMPTY_PATH_POSITIONS, navigationPointProvider, neighborStrategy, pathfinderConfiguration, validationProcessors -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected NodeextractBestNode(MinHeap openSet) Extracts the node with the lowest cost from the open set and retrieves the corresponding Node object.protected voidPrepares the algorithm-specific initial setup required before executing the pathfinding logic.protected voidinsertStartNode(Node node, double fCost, MinHeap openSet) Inserts the start node into the open set and updates any internal mapping.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, MinHeap 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
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
-
insertStartNode
Description copied from class:AbstractPathfinderInserts the start node into the open set and updates any internal mapping.- Specified by:
insertStartNodein classAbstractPathfinder
-
extractBestNode
Description copied from class:AbstractPathfinderExtracts the node with the lowest cost from the open set and retrieves the corresponding Node object.- Specified by:
extractBestNodein classAbstractPathfinder
-
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, MinHeap 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 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
-