Compare commits

...

3 Commits

Author SHA1 Message Date
62d527737a remove unnecessary default value 2024-07-29 01:34:08 +02:00
25069630a7 add debug message when loading a way 2024-07-29 01:33:27 +02:00
cb2510a2a1 Remove additional calls to ExploreSide 2024-07-29 01:31:50 +02:00

View File

@ -52,8 +52,6 @@ namespace astar
for(int i = 0; i < Math.Min(toVisitStart.Count * 0.5, 50) && meetingEnds is null; i++) for(int i = 0; i < Math.Min(toVisitStart.Count * 0.5, 50) && meetingEnds is null; i++)
meetingEnds = ExploreSide(true, graph, toVisitStart, rl, priorityHelper, closestEndNode, car, DefaultPriorityWeights, pathing, logger); meetingEnds = ExploreSide(true, graph, toVisitStart, rl, priorityHelper, closestEndNode, car, DefaultPriorityWeights, pathing, logger);
} }
if(meetingEnds is null)
meetingEnds = ExploreSide(true, graph, toVisitStart, rl, priorityHelper, closestEndNode, car, DefaultPriorityWeights, pathing, logger);
ulong closestStartNodeId = toVisitStart.UnorderedItems ulong closestStartNodeId = toVisitStart.UnorderedItems
.MinBy(n => graph.Nodes[n.Element].DistanceTo(endNode.Value)).Element; .MinBy(n => graph.Nodes[n.Element].DistanceTo(endNode.Value)).Element;
@ -63,8 +61,6 @@ namespace astar
for(int i = 0; i < Math.Min(toVisitEnd.Count * 0.5, 50) && meetingEnds is null; i++) for(int i = 0; i < Math.Min(toVisitEnd.Count * 0.5, 50) && meetingEnds is null; i++)
meetingEnds = ExploreSide(false, graph, toVisitEnd, rl, priorityHelper, closestStartNode, car, DefaultPriorityWeights, pathing, logger); meetingEnds = ExploreSide(false, graph, toVisitEnd, rl, priorityHelper, closestStartNode, car, DefaultPriorityWeights, pathing, logger);
} }
if(meetingEnds is null)
meetingEnds = ExploreSide(false, graph, toVisitEnd, rl, priorityHelper, closestStartNode, car, DefaultPriorityWeights, pathing, logger);
if (meetingEnds is not null) if (meetingEnds is not null)
break; break;
@ -88,7 +84,7 @@ namespace astar
return PathFound(graph, meetingEnds!.Value.Item1, meetingEnds.Value.Item2, car, logger); return PathFound(graph, meetingEnds!.Value.Item1, meetingEnds.Value.Item2, car, logger);
} }
private static ValueTuple<Node, Node>? ExploreSide(bool fromStart, Graph graph, PriorityQueue<ulong, int> toVisit, RegionLoader rl, PriorityHelper priorityHelper, Node goalNode, bool car, ValueTuple<float,float,float,float> ratingWeights, PathMeasure pathing = PathMeasure.Distance, ILogger? logger = null) private static ValueTuple<Node, Node>? ExploreSide(bool fromStart, Graph graph, PriorityQueue<ulong, int> toVisit, RegionLoader rl, PriorityHelper priorityHelper, Node goalNode, bool car, ValueTuple<float,float,float,float> ratingWeights, PathMeasure pathing, ILogger? logger = null)
{ {
ulong currentNodeId = toVisit.Dequeue(); ulong currentNodeId = toVisit.Dequeue();
Node currentNode = graph.Nodes[currentNodeId]; Node currentNode = graph.Nodes[currentNodeId];
@ -99,6 +95,7 @@ namespace astar
graph.ConcatGraph(Graph.FromGraph(rl.LoadRegionFromNodeId(neighborId))); graph.ConcatGraph(Graph.FromGraph(rl.LoadRegionFromNodeId(neighborId)));
if (!graph.ContainsWay(wayId.Key)) if (!graph.ContainsWay(wayId.Key))
{ {
logger?.LogDebug("Loading way... This will be slow.");
foreach (global::Graph.Graph? g in rl.LoadRegionsFromWayId(wayId.Key)) foreach (global::Graph.Graph? g in rl.LoadRegionsFromWayId(wayId.Key))
graph.ConcatGraph(Graph.FromGraph(g)); graph.ConcatGraph(Graph.FromGraph(g));
} }