Removed/Replaced unnecessary checks in AStar.

This commit is contained in:
glax 2023-04-20 22:53:23 +02:00
parent b87d8a0300
commit 90a09e84c5

View File

@ -62,14 +62,9 @@ public class Pathfinder
gScore.TryAdd(neighbor, double.MaxValue);
if (tentativeGScore < gScore[neighbor])
{
if (cameFromDict.ContainsKey(neighbor))
if(!cameFromDict.TryAdd(neighbor, currentNode))
cameFromDict[neighbor] = currentNode;
else
cameFromDict.Add(neighbor, currentNode);
if (gScore.ContainsKey(neighbor))
gScore[neighbor] = tentativeGScore;
else
gScore.Add(neighbor, tentativeGScore);
gScore[neighbor] = tentativeGScore;
double h = Heuristic(currentNode, neighbor, goalNode, edge, vehicle,
heuristicRoadLevelPriority, heuristicFewJunctionsPriority, heuristicSameRoadPriority);
//Console.WriteLine($"Queue: {openSetfScore.Count:00000} Current Distance: {Utils.DistanceBetween(currentNode, goalNode):000000.00} Visited: {cameFromDict.Count:00000} Current heuristic: {h:00000.00}");