Ends try to find closest node to one another.
This commit is contained in:
parent
ffa2e5abe9
commit
55c753adb8
@ -44,21 +44,27 @@ namespace astar
|
|||||||
ValueTuple<Node, Node>? meetingEnds = null;
|
ValueTuple<Node, Node>? meetingEnds = null;
|
||||||
while (toVisitStart.Count > 0 && toVisitEnd.Count > 0)
|
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)
|
if (toVisitStart.Count >= toVisitEnd.Count && meetingEnds is null)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < toVisitStart.Count / 10 && meetingEnds is null; i++)
|
for(int i = 0; i < toVisitStart.Count / 10 && meetingEnds is null; i++)
|
||||||
meetingEnds = ExploreSide(true, graph, toVisitStart, rl, priorityHelper, endNode.Value, car, DefaultPriorityWeights, pathing, logger);
|
meetingEnds = ExploreSide(true, graph, toVisitStart, rl, priorityHelper, closestEndNode, car, DefaultPriorityWeights, pathing, logger);
|
||||||
}
|
}
|
||||||
if(meetingEnds is null)
|
if(meetingEnds is null)
|
||||||
meetingEnds = ExploreSide(true, graph, toVisitStart, rl, priorityHelper, endNode.Value, car, DefaultPriorityWeights, pathing, logger);
|
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)
|
if (toVisitEnd.Count >= toVisitStart.Count && meetingEnds is null)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < toVisitEnd.Count / 10 && meetingEnds is null; i++)
|
for(int i = 0; i < toVisitEnd.Count / 10 && meetingEnds is null; i++)
|
||||||
meetingEnds = ExploreSide(false, graph, toVisitEnd, rl, priorityHelper, startNode.Value, car, DefaultPriorityWeights, pathing, logger);
|
meetingEnds = ExploreSide(false, graph, toVisitEnd, rl, priorityHelper, closestStartNode, car, DefaultPriorityWeights, pathing, logger);
|
||||||
}
|
}
|
||||||
if(meetingEnds is null)
|
if(meetingEnds is null)
|
||||||
meetingEnds = ExploreSide(false, graph, toVisitEnd, rl, priorityHelper, startNode.Value, car, DefaultPriorityWeights, pathing, logger);
|
meetingEnds = ExploreSide(false, graph, toVisitEnd, rl, priorityHelper, closestStartNode, car, DefaultPriorityWeights, pathing, logger);
|
||||||
|
|
||||||
if (meetingEnds is not null)
|
if (meetingEnds is not null)
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user