From f411d08c99a1a00a35b12665b4e2b3b22c65f9e1 Mon Sep 17 00:00:00 2001 From: KaiFieger Date: Sun, 15 Sep 2024 16:38:04 +0200 Subject: [PATCH] fixed A* implementation in bracket-pathfinding --- bracket-pathfinding/src/astar.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bracket-pathfinding/src/astar.rs b/bracket-pathfinding/src/astar.rs index c46c15a9..6d0306f4 100755 --- a/bracket-pathfinding/src/astar.rs +++ b/bracket-pathfinding/src/astar.rs @@ -109,13 +109,13 @@ impl AStar { let s = Node { idx, f: q.g + cost + distance_to_end, - g: cost, + g: q.g + cost, }; // If a node with the same position as successor is in the open list with a lower f, skip add let mut should_add = true; if let Some(e) = self.parents.get(&idx) { - if e.1 < s.g { + if e.1 <= s.g { should_add = false; } }