diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-03-29 20:33:33 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-03-29 20:33:33 +0300 |
| commit | 0da3ed44b904b3e5c8d61a236069b2fff1508a7f (patch) | |
| tree | c21bb4caea83766f92b01d072180455825766b1a | |
| parent | 3cdb2a67a452ec39dc13268ab86c11e737685073 (diff) | |
| download | astar-0da3ed44b904b3e5c8d61a236069b2fff1508a7f.tar.xz | |
Make manhattan_distance() use COST_ORTHOGONAL
| -rw-r--r-- | path.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -8,6 +8,7 @@ #include "structs.h" #include "priority_queue.h" #include "error.h" +#include "config.h" /* TODO: somehow get offsets back to main */ int anim(Map map, size_t width, size_t height, Position start, Position end, Position *cur, char **visited, PositionPQ *frontier) { @@ -149,14 +150,14 @@ Path dijkstra_path(int dirs, Map map, size_t width, size_t height, Position star size_t manhattan_distance(Position a, Position b) { size_t d = 0; if (a.x > b.x) { - d += a.x - b.x; + d += (a.x - b.x) * COST_ORTHOGONAL; } else { - d += b.x - a.x; + d += (b.x - a.x) * COST_ORTHOGONAL; } if (a.y > b.y) { - d += a.y - b.y; + d += (a.y - b.y) * COST_ORTHOGONAL; } else { - d += b.y - a.y; + d += (b.y - a.y) * COST_ORTHOGONAL; } return d; } |
