diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pathfinding.adb | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/pathfinding.adb b/src/pathfinding.adb index 267b0a3..7f683ce 100644 --- a/src/pathfinding.adb +++ b/src/pathfinding.adb @@ -147,7 +147,6 @@ package body Pathfinding is Came_From : Node_To_Node_Maps.Map := Node_To_Node_Maps.Empty_Map; New_G_Score : G_Score; - New_F_Score : F_Score; begin G_Scores := G_Score_Maps.Empty_Map; G_Scores.Insert (Start, 0); @@ -164,17 +163,14 @@ package body Pathfinding is Closed_Set.Insert (Current); for N of Neighbours (My_Grid, Current) loop if not Closed_Set.Contains (N) then - if not Open_Set.Contains (N) then - Open_Set.Insert (N); - end if; New_G_Score := G_Scores.Element (Current) + 1; - New_F_Score := New_G_Score + Heuristic (N, Goal); if not G_Scores.Contains (N) or else New_G_Score < G_Scores.Element (N) then - Came_From.Insert (N, Current); - G_Scores.Insert (N, New_G_Score); - F_Scores.Insert (N, New_F_Score); + Came_From.Include (N, Current); + G_Scores.Include (N, New_G_Score); + F_Scores.Include (N, New_G_Score + Heuristic (N, Goal)); + Open_Set.Include (N); end if; end if; end loop; |