aboutsummaryrefslogtreecommitdiff
path: root/src/pathfinding.adb
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-04-16 15:51:58 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2025-04-16 15:51:58 +1200
commitbaa3a346cde2c2c965243e554a15ed3bd6f5c7fe (patch)
treef8ec8376a6a42053e15cb9607b0fef17bb4f321d /src/pathfinding.adb
parentb3455e502f4491af22e190a14aba9565f534bb59 (diff)
Code style improvements, constants marked as constant
Diffstat (limited to 'src/pathfinding.adb')
-rw-r--r--src/pathfinding.adb9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/pathfinding.adb b/src/pathfinding.adb
index 9e45ec1..5234cdb 100644
--- a/src/pathfinding.adb
+++ b/src/pathfinding.adb
@@ -14,11 +14,13 @@ package body Pathfinding is
X, Y : Integer;
end record;
+
function "<" (A, B : in Node) return Boolean is
begin
return A.X < B.X or (A.X = B.X and A.Y < B.Y);
end "<";
+
package Node_Sets is new Ada.Containers.Ordered_Sets
(Element_Type => Node);
package Node_To_Node_Maps is new Ada.Containers.Ordered_Maps
@@ -30,11 +32,13 @@ package body Pathfinding is
subtype G_Score is Integer;
subtype F_Score is Integer;
+
package G_Score_Maps is new Ada.Containers.Ordered_Maps
(Key_Type => Node, Element_Type => G_Score);
package F_Score_Maps is new Ada.Containers.Ordered_Maps
(Key_Type => Node, Element_Type => F_Score);
+
G_Scores : G_Score_Maps.Map := G_Score_Maps.Empty_Map;
F_Scores : F_Score_Maps.Map := F_Score_Maps.Empty_Map;
@@ -135,8 +139,8 @@ package body Pathfinding is
is
use type Node_Sets.Set;
- Start : Node := (X => SX, Y => SY);
- Goal : Node := (X => FX, Y => FY);
+ Start : constant Node := (X => SX, Y => SY);
+ Goal : constant Node := (X => FX, Y => FY);
Current : Node;
Closed_Set : Node_Sets.Set := Node_Sets.Empty_Set;
@@ -191,3 +195,4 @@ package body Pathfinding is
end Pathfinding;
+