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

Method LeastCostEstimate

Source/Map/Random.cpp:384–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382}
383
384float cRandomMap::LeastCostEstimate(cPosition* nodeStart, cPosition* nodeEnd) {
385
386 /* Compute the minimum path cost using distance measurement. It is possible
387 to compute the exact minimum path using the fact that you can move only
388 on a straight line or on a diagonal, and this will yield a better result.
389 */
390 int dx = nodeStart->mX - nodeEnd->mX;
391 int dy = nodeStart->mY - nodeEnd->mY;
392 return (float)sqrt((double)(dx*dx) + (double)(dy*dy));
393}
394
395void cRandomMap::AdjacentCost(cPosition* node, std::vector< micropather::StateCost > *neighbors) {
396 const int dx[8] = { 8, 8, 0, -8, -8, -8, 0, 8 };

Callers 1

SolveMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected