From ef67b5cf5e9facd26ba8ff52e0508613b38557dc Mon Sep 17 00:00:00 2001 From: Brychan Dempsey Date: Sat, 23 Oct 2021 01:12:15 +1300 Subject: [PATCH] Fixed heuristic not being calculated for the child nodes correctly --- ShortestTotalPath/Program.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ShortestTotalPath/Program.cs b/ShortestTotalPath/Program.cs index 25906f7..e10ba1f 100644 --- a/ShortestTotalPath/Program.cs +++ b/ShortestTotalPath/Program.cs @@ -62,8 +62,9 @@ namespace ShortestTotalPath Console.Write(" -> "); } } + } - + Console.WriteLine("Finished"); Console.ReadLine(); } @@ -134,7 +135,7 @@ namespace ShortestTotalPath double length = poppedNode.TotalTraversedLength + poppedNode.Children[child]; Node qNode = new(child, poppedNode, length); // A admissible (never over-estimates) heuristic is largest distance to an un-traversed node from our current node. - qNode.LocalHeuristic = poppedNode.FarthestUnvisitedNodeDistance(); + qNode.LocalHeuristic = qNode.FarthestUnvisitedNodeDistance(); // Add the node to the queue queue.Add(qNode, length); }