Change closest node for ExploreSide, fix toVisitEnd never being used

This commit is contained in:
glax 2024-07-29 15:17:12 +02:00
parent 793dd68cfd
commit a84d31c882

View File

@ -43,22 +43,18 @@ namespace astar
ValueTuple<Node, Node>? meetingEnds = null;
while (toVisitStart.Count > 0 && toVisitEnd.Count > 0)
{
ulong closestEndNodeId = toVisitEnd.UnorderedItems
.MinBy(n => graph.Nodes[n.Element].DistanceTo(startNode.Value)).Element;
Node closestEndNode = graph.Nodes[closestEndNodeId];
if (toVisitStart.Count >= toVisitEnd.Count && meetingEnds is null)
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);
ulong closestEndNodeId = toVisitEnd.UnorderedItems.MinBy(node => graph.Nodes[node.Element].DistanceTo(graph.Nodes[toVisitStart.Peek()])).Element;
Node closestEndNode = graph.Nodes[closestEndNodeId];
meetingEnds = ExploreSide(true, graph, toVisitStart, rl, priorityHelper, closestEndNode, car, DefaultPriorityWeights, pathing, logger);
}
ulong closestStartNodeId = toVisitStart.UnorderedItems
.MinBy(n => graph.Nodes[n.Element].DistanceTo(endNode.Value)).Element;
Node closestStartNode = graph.Nodes[closestStartNodeId];
if (toVisitEnd.Count >= toVisitStart.Count && meetingEnds is null)
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);
ulong closestStartNodeId = toVisitStart.UnorderedItems.MinBy(node => graph.Nodes[node.Element].DistanceTo(graph.Nodes[toVisitEnd.Peek()])).Element;
Node closestStartNode = graph.Nodes[closestStartNodeId];
meetingEnds = ExploreSide(false, graph, toVisitEnd, rl, priorityHelper, closestStartNode, car, DefaultPriorityWeights, pathing, logger);
}
if (meetingEnds is not null)