#include <micropather.h>
Public Member Functions | |
| MicroPather (Graph *graph, unsigned allocate=250, unsigned typicalAdjacent=6) | |
| int | Solve (void *startState, void *endState, std::vector< void * > *path, float *totalCost) |
| int | SolveForNearStates (void *startState, std::vector< StateCost > *near, float maxCost) |
| void | Reset () |
| MP_UPTR | Checksum () |
| micropather::MicroPather::MicroPather | ( | Graph * | graph, | |
| unsigned | allocate = 250, |
|||
| unsigned | typicalAdjacent = 6 | |||
| ) |
Construct the pather, passing a pointer to the object that implements the Graph callbacks.
| graph | The "map" that implements the Graph callbacks. | |
| allocate | How many states should be internally allocated at a time. This can be hard to get correct. The higher the value, the more memory MicroPather will use.
| |
| typicalAdjacent | Used to determine cache size. The typical number of adjacent states to a given state. (On a chessboard, 8.) Higher values use a little more memory. |
| int micropather::MicroPather::Solve | ( | void * | startState, | |
| void * | endState, | |||
| std::vector< void * > * | path, | |||
| float * | totalCost | |||
| ) |
Solve for the path from start to end.
| startState | Input, the starting state for the path. | |
| endState | Input, the ending state for the path. | |
| path | Output, a vector of states that define the path. Empty if not found. | |
| totalCost | Output, the cost of the path, if found. |
| int micropather::MicroPather::SolveForNearStates | ( | void * | startState, | |
| std::vector< StateCost > * | near, | |||
| float | maxCost | |||
| ) |
Find all the states within a given cost from startState.
| startState | Input, the starting state for the path. | |
| near | All the states within 'maxCost' of 'startState', and cost to that state. | |
| maxCost | Input, the maximum cost that will be returned. (Higher values return larger 'near' sets and take more time to compute.) |
| void micropather::MicroPather::Reset | ( | ) |
Should be called whenever the cost between states or the connection between states changes. Also frees overhead memory used by MicroPather, and calling will free excess memory.
| MP_UPTR micropather::MicroPather::Checksum | ( | ) | [inline] |
Return the "checksum" of the last path returned by Solve(). Useful for debugging, and a quick way to see if 2 paths are the same.
1.5.1-p1