#include <pathfinderastargenericcached.h>
Classes | |
| class | AddNeighborFunctor |
| Functor passed to the IGetNeighbors functor. More... | |
| class | IGetNeighbors |
| Functor interface for getting the neighbor states of a given state. More... | |
Public Member Functions | |
| const PathResult | FindPath (const NODETYPE &start, const long startindex, const NODETYPE &goal, std::vector< NODETYPE > &finalpath, DESTCOST &destinationcost, GETNEIGHBORS &getneighbors) |
| Finds a path between two states. | |
| void | InitializeStep (const NODETYPE &start, const long startindex, const NODETYPE &goal, DESTCOST &destcost, GETNEIGHBORS &getneighbors) |
| Initializes the path finder for single stepping. | |
| const PathResult | Step () |
| Single steps the path finder. | |
| void | GetPath (std::vector< NODETYPE > &path) |
| Gets the current path. | |
| void | ClearCache () |
| Clears the cache. | |
| void | ClearCacheIndex (const long index) |
| Clears one cache element. | |
This is a generic A * path finding class. The movement costs from state to state are cached to maximize performance. If state change costs can change frequently, you should use the non-cached version of this class.
In order to cache the state change costs, each state requires a unique index with a value >= 0.
| NODETYPE | Defines a state of the pathfinder, typically an x,y coordinate for tile based games | |
| DESTCOST | A functor implementing IDestinationCost | |
| GETNEIGHBORS | A functor implementing IGetNeighbors | |
| COSTTYPE | The cost type of moving from state to state, typically a float or double |
| void Pathfinder::AStarGenericCached< NODETYPE, DESTCOST, GETNEIGHBORS, COSTTYPE >::ClearCacheIndex | ( | const long | index | ) | [inline] |
Clears one cache element.
Call this method when the cost of reaching a state has changed.
| index | The index of the state to clear |
| const PathResult Pathfinder::AStarGenericCached< NODETYPE, DESTCOST, GETNEIGHBORS, COSTTYPE >::FindPath | ( | const NODETYPE & | start, | |
| const long | startindex, | |||
| const NODETYPE & | goal, | |||
| std::vector< NODETYPE > & | finalpath, | |||
| DESTCOST & | destinationcost, | |||
| GETNEIGHBORS & | getneighbors | |||
| ) | [inline] |
Finds a path between two states.
This method will block until a path from the start to the goal is found or all reachable nodes have been checked without finding a path.
| start | The starting state | |
| startindex | The index of the starting state | |
| goal | The goal state | |
| [out] | finalpath | A vector of states from the starting state to the goal state |
| destinationcost | User supplied functor implementing IDestinationCost | |
| getneighbors | User supplied functor implementing IGetNeighbors |
| void Pathfinder::AStarGenericCached< NODETYPE, DESTCOST, GETNEIGHBORS, COSTTYPE >::GetPath | ( | std::vector< NODETYPE > & | path | ) | [inline] |
Gets the current path.
This is usually called to get a complete path after Step returns PATH_FOUND, but it may be called at any step of the path finding, wheter a complete path has been found or not.
| [out] | path | A vector of states from the starting state to the current state |
| void Pathfinder::AStarGenericCached< NODETYPE, DESTCOST, GETNEIGHBORS, COSTTYPE >::InitializeStep | ( | const NODETYPE & | start, | |
| const long | startindex, | |||
| const NODETYPE & | goal, | |||
| DESTCOST & | destcost, | |||
| GETNEIGHBORS & | getneighbors | |||
| ) | [inline] |
Initializes the path finder for single stepping.
| start | The starting state | |
| startindex | The index of the starting state | |
| goal | The goal state | |
| destcost | User supplied functor IDestinationCost | |
| getneighbors | User supplied functor IGetNeighbors |
| const PathResult Pathfinder::AStarGenericCached< NODETYPE, DESTCOST, GETNEIGHBORS, COSTTYPE >::Step | ( | ) | [inline] |
Single steps the path finder.
1.5.7.1