aboutsummaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-03-29 20:33:33 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-03-29 20:33:33 +0300
commit0da3ed44b904b3e5c8d61a236069b2fff1508a7f (patch)
treec21bb4caea83766f92b01d072180455825766b1a /path.c
parent3cdb2a67a452ec39dc13268ab86c11e737685073 (diff)
downloadastar-0da3ed44b904b3e5c8d61a236069b2fff1508a7f.tar.xz
Make manhattan_distance() use COST_ORTHOGONAL
Diffstat (limited to 'path.c')
-rw-r--r--path.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/path.c b/path.c
index 64b2d95..bc3d6c5 100644
--- a/path.c
+++ b/path.c
@@ -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;
}