MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / Graph

Class Graph

Source/Utils/micropather.h:160–187  ·  view source on GitHub ↗

A pure abstract class used to define a set of callbacks. The client application inherits from this class, and the methods will be called when MicroPather::Solve() is invoked. The notion of a "state" is very important. It must have the following properties: - Unique - Unchanging (unless MicroPather::Reset() is called) If the client application represents states as objects, then the

Source from the content-addressed store, hash-verified

158 never interprets or modifies the value of state.
159 */
160 class Graph
161 {
162 public:
163 virtual ~Graph() {}
164
165 /**
166 Return the least possible cost between 2 states. For example, if your pathfinding
167 is based on distance, this is simply the straight distance between 2 points on the
168 map. If you pathfinding is based on minimum time, it is the minimal travel time
169 between 2 points given the best possible terrain.
170 */
171 virtual float LeastCostEstimate( cPosition* stateStart, cPosition* stateEnd ) = 0;
172
173 /**
174 Return the exact cost from the given state to all its neighboring states. This
175 may be called multiple times, or cached by the solver. It *must* return the same
176 exact values for every call to MicroPather::Solve(). It should generally be a simple,
177 fast function with no callbacks into the pather.
178 */
179 virtual void AdjacentCost( cPosition* state, MP_VECTOR< micropather::StateCost > *adjacent ) = 0;
180
181 /**
182 This function is only used in DEBUG mode - it dumps output to stdout. Since cPosition*
183 aren't really human readable, normally you print out some concise info (like "(1,2)")
184 without an ending newline.
185 */
186 virtual void PrintStateInfo( cPosition* state ) = 0;
187 };
188
189
190 class PathNode;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected