MCPcopy Create free account
hub / github.com/diasurgical/devilution / path_get_h_cost

Function path_get_h_cost

Source/path.cpp:92–102  ·  view source on GitHub ↗

* @brief heuristic, estimated cost from (sx,sy) to (dx,dy) */

Source from the content-addressed store, hash-verified

90 * @brief heuristic, estimated cost from (sx,sy) to (dx,dy)
91 */
92int path_get_h_cost(int sx, int sy, int dx, int dy)
93{
94 int delta_x = abs(sx - dx);
95 int delta_y = abs(sy - dy);
96
97 int min = delta_x < delta_y ? delta_x : delta_y;
98 int max = delta_x > delta_y ? delta_x : delta_y;
99
100 // see path_check_equal for why this is times 2
101 return 2 * (min + max);
102}
103
104/**
105 * @brief return 2 if pPath is horizontally/vertically aligned with (dx,dy), else 3

Callers 2

FindPathFunction · 0.85
path_parent_pathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected