#include <micropather.h>
|
enum | { SOLVED,
NO_SOLUTION,
START_END_SAME,
NOT_CACHED
} |
|
Create a MicroPather object to solve for a best path. Detailed usage notes are on the main page.
◆ MicroPather()
Tetraedge::micropather::MicroPather::MicroPather |
( |
Graph * |
graph, |
|
|
unsigned |
allocate = 250 , |
|
|
unsigned |
typicalAdjacent = 6 , |
|
|
bool |
cache = true |
|
) |
| |
Construct the pather, passing a pointer to the object that implements the Graph callbacks.
- Parameters
-
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.
- If you have a small map (a few thousand states?) it may make sense to pass in the maximum value. This will cache everything, and MicroPather will only need one main memory allocation. For a chess board, allocate would be set to 8x8 (64)
- If your map is large, something like 1/4 the number of possible states is good.
- If your state space is huge, use a multiple (5-10x) of the normal path. "Occasionally" call Reset() to free unused memory.
|
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. |
cache | Turn on path caching. Uses more memory (yet again) but at a huge speed advantage if you may call the pather with the same path or sub-path, which is common for pathing over maps in games. |
◆ Solve()
int Tetraedge::micropather::MicroPather::Solve |
( |
void * |
startState, |
|
|
void * |
endState, |
|
|
Common::Array< void * > * |
path, |
|
|
float * |
totalCost |
|
) |
| |
Solve for the path from start to end.
- Parameters
-
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. |
- Returns
- Success or failure, expressed as SOLVED, NO_SOLUTION, or START_END_SAME.
◆ SolveForNearStates()
int Tetraedge::micropather::MicroPather::SolveForNearStates |
( |
void * |
startState, |
|
|
Common::Array< StateCost > * |
near, |
|
|
float |
maxCost |
|
) |
| |
Find all the states within a given cost from startState.
- Parameters
-
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.) |
- Returns
- Success or failure, expressed as SOLVED or NO_SOLUTION.
◆ Reset()
void Tetraedge::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.
The documentation for this class was generated from the following file: