summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2024-07-26 09:54:46 +0200
committerMitya Selivanov <automainint@guattari.tech>2024-07-26 09:54:46 +0200
commit7524b8ebf395b4b536591175880f5d9644e0a9f9 (patch)
tree0469a19103fe3dbca9638392e96bf7fce65c35f1
parent1317e9d2334fc9af5055bd8ef6f4064b4469a15b (diff)
downloadkit-dev.zip
A*: Fix nearest node searchHEADdev
-rw-r--r--source/kit/astar.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/source/kit/astar.h b/source/kit/astar.h
index b76ef67..6f0d1b5 100644
--- a/source/kit/astar.h
+++ b/source/kit/astar.h
@@ -227,7 +227,8 @@ static s32 NAME_(astar_iteration)(Astar_State *state) {
{
i64 index_in_open = 0;
for (i64 i = 1; i < state->open.size; i++)
- if (state->open.values[i].estimate < state->open.values[index_in_open].estimate)
+ if (state->open.values[i] .exact_distance + state->open.values[i] .estimate <
+ state->open.values[index_in_open].exact_distance + state->open.values[index_in_open].estimate)
index_in_open = i;
nearest_node = state->open.values[index_in_open];
if (index_in_open != state->open.size - 1)