micropather::MicroPather Class Reference

#include <micropather.h>

List of all members.

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 ()


Detailed Description

Create a MicroPather object to solve for a best path. Detailed usage notes are on the main page.


Constructor & Destructor Documentation

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.

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. For example, Lilith3D normally has about 16,000 states, so 'allocate' should be about 4000.
  • 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.


Member Function Documentation

int micropather::MicroPather::Solve ( void *  startState,
void *  endState,
std::vector< 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.

int micropather::MicroPather::SolveForNearStates ( void *  startState,
std::vector< 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.

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.


The documentation for this class was generated from the following file:
Generated on Sun Dec 6 09:25:42 2009 for MicroPather by  doxygen 1.5.1-p1