Removed/Replaced unnecessary checks in AStar.
This commit is contained in:
parent
b87d8a0300
commit
90a09e84c5
@ -62,14 +62,9 @@ public class Pathfinder
|
|||||||
gScore.TryAdd(neighbor, double.MaxValue);
|
gScore.TryAdd(neighbor, double.MaxValue);
|
||||||
if (tentativeGScore < gScore[neighbor])
|
if (tentativeGScore < gScore[neighbor])
|
||||||
{
|
{
|
||||||
if (cameFromDict.ContainsKey(neighbor))
|
if(!cameFromDict.TryAdd(neighbor, currentNode))
|
||||||
cameFromDict[neighbor] = currentNode;
|
cameFromDict[neighbor] = currentNode;
|
||||||
else
|
gScore[neighbor] = tentativeGScore;
|
||||||
cameFromDict.Add(neighbor, currentNode);
|
|
||||||
if (gScore.ContainsKey(neighbor))
|
|
||||||
gScore[neighbor] = tentativeGScore;
|
|
||||||
else
|
|
||||||
gScore.Add(neighbor, tentativeGScore);
|
|
||||||
double h = Heuristic(currentNode, neighbor, goalNode, edge, vehicle,
|
double h = Heuristic(currentNode, neighbor, goalNode, edge, vehicle,
|
||||||
heuristicRoadLevelPriority, heuristicFewJunctionsPriority, heuristicSameRoadPriority);
|
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}");
|
//Console.WriteLine($"Queue: {openSetfScore.Count:00000} Current Distance: {Utils.DistanceBetween(currentNode, goalNode):000000.00} Visited: {cameFromDict.Count:00000} Current heuristic: {h:00000.00}");
|
||||||
|
Reference in New Issue
Block a user