internal static Queue <DungeonNode> GetWeightedNearestMinimapVisitedRoute() { Stopwatch timer = new Stopwatch(); timer.Start(); Vector3 myPosition = ZetaDia.Me.Position; Queue <DungeonNode> route = new Queue <DungeonNode>(); List <WeightedDungeonNode> weightedNodes = new List <WeightedDungeonNode>(); // We want to give a high weight to nodes which have Explored nodes near it // A maximum weight will be given to an unexplored node with 4 directly connected explored (facing) nodes, and 4 corner-connected nodes // This is theoretically possible if we are standing IN this maximum-weighted unexplored node // Typically a node will have 1 or more directly connected nodes and 0 or more corner-connected nodes foreach (var unWeightedNode in UnVisitedNodes) { var weightedNode = new WeightedDungeonNode(unWeightedNode.WorldTopLeft, unWeightedNode.WorldBottomRight) { Weight = 0 }; // Number of visited nodes connected to this unvisited node will give higher weight int numNodesConnected = VisitedNodes.Count(node => node.GridCenter.DistanceSqr(weightedNode.GridCenter) <= (MaxCornerDistance * MaxCornerDistance)); weightedNode.Weight = numNodesConnected / MaxConnectedNodes; weightedNodes.Add(weightedNode); } foreach (var node in weightedNodes.OrderByDescending(n => (1 / n.NavigableCenter.Distance(myPosition)) * n.Weight)) { if (SetNodesExploredAutomatically && ZetaDia.Minimap.IsExplored(node.NavigableCenter, ZetaDia.CurrentWorldDynamicId)) { continue; } route.Enqueue(node); } Logger.Log("Generated new Weighted Nearest Minimap Visited Route with {0} nodes in {1}ms", route.Count, timer.ElapsedMilliseconds); return(route); }