summaryrefslogtreecommitdiff
path: root/src/pathfinding.adb
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2017-08-06 22:17:54 +1000
committerJed Barber <jjbarber@y7mail.com>2017-08-06 22:17:54 +1000
commit7cef684e71b64f00b41da66ba7bc581568d78f51 (patch)
treec187a50b13961b0cd8227dd0d54ec7958f131bbf /src/pathfinding.adb
parent051ddb2a265dda897bce72edc318beadd111eba2 (diff)
Factored out some trivial bits into Misc, made coding style more consistent
Diffstat (limited to 'src/pathfinding.adb')
-rw-r--r--src/pathfinding.adb24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/pathfinding.adb b/src/pathfinding.adb
index 1435ecf..9e45ec1 100644
--- a/src/pathfinding.adb
+++ b/src/pathfinding.adb
@@ -143,6 +143,9 @@ package body Pathfinding is
Open_Set : Node_Sets.Set := Node_Sets.To_Set (Start);
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);
@@ -162,18 +165,15 @@ package body Pathfinding is
if not Open_Set.Contains (N) then
Open_Set.Insert (N);
end if;
- declare
- New_G_Score : G_Score := G_Scores.Element (Current) + 1;
- New_F_Score : F_Score := New_G_Score + Heuristic (N, Goal);
- begin
- 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);
- end if;
- end;
+ 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);
+ end if;
end if;
end loop;
end loop;