From baa3a346cde2c2c965243e554a15ed3bd6f5c7fe Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 16 Apr 2025 15:51:58 +1200 Subject: Code style improvements, constants marked as constant --- src/pathfinding.adb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/pathfinding.adb') 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; + -- cgit