Beispiel #1
0
        internal static void Reset(int boxSize = 30, float boxTolerance = 0.05f)
        {
            GridSegmentation.Reset(boxSize, boxTolerance);

            switch (RouteMode)
            {
            case RouteMode.SceneDirection:
            case RouteMode.SceneTSP:
                SceneSegmentation.Reset();
                break;
            }

            Update();
        }
Beispiel #2
0
        /// <summary>
        /// Uses Nearest Neighbor Simple TSP
        /// </summary>
        /// <returns></returns>
        internal static Queue <DungeonNode> GetSceneNearestNeighborRoute()
        {
            Stopwatch timer = new Stopwatch();

            timer.Start();
            Vector3 myPosition = ZetaDia.Me.Position;

            SceneSegmentation.Update();

            if (!UnVisitedNodes.Any())
            {
                return(default(Queue <DungeonNode>));
            }

            List <DungeonNode> unsortedNodes = UnVisitedNodes.ToList();
            List <DungeonNode> sortedNodes   = new List <DungeonNode>();

            var nearestNode = unsortedNodes
                              .OrderBy(node => ZetaDia.Minimap.IsExplored(node.NavigableCenter, ZetaDia.Me.WorldDynamicId))
                              .ThenBy(node => node.NavigableCenter.Distance2DSqr(myPosition))
                              .First();

            sortedNodes.Add(nearestNode);
            unsortedNodes.Remove(nearestNode);

            Dictionary <Vector2, bool> nodeExploredMap = unsortedNodes
                                                         .ToDictionary(node => node.WorldTopLeft, node => ZetaDia.Minimap.IsExplored(node.NavigableCenter, ZetaDia.Me.WorldDynamicId));

            // Enqueue closest node
            while (unsortedNodes.Any())
            {
                var nextNode = unsortedNodes
                               // Minimap Unvisited first
                               .OrderBy(n => nodeExploredMap[n.WorldTopLeft])
                               .ThenBy(n => n.Center.DistanceSqr(sortedNodes.Last().Center))
                               .First();
                sortedNodes.Add(nextNode);
                unsortedNodes.Remove(nextNode);
            }

            Queue <DungeonNode> route = new Queue <DungeonNode>(sortedNodes);

            Logger.Log("Generated new Scene Route with {0} nodes in {1}ms", route.Count, timer.ElapsedMilliseconds);
            return(route);
        }
Beispiel #3
0
        internal static void Update()
        {
            switch (RouteMode)
            {
            case RouteMode.Default:
                UpdateDungeonExplorer();
                break;

            case RouteMode.SceneTSP:
            case RouteMode.SceneDirection:
                SceneSegmentation.Update();
                break;

            default:
                UpdateGridSegmentation();
                break;
            }

            _currentRoute = GetRoute();
        }