コード例 #1
0
ファイル: Form1.cs プロジェクト: romanzedd/FSTSP
        private void doTruck(List <Order> truckOrders)
        {
            List <List <Location> > truckPaths = new List <List <Location> >();
            List <Location>         path;

            AStarSearch astar = new AStarSearch(groundGrid, Depot, new Location(truckOrders.First().x, truckOrders.First().y, 0));

            path = astar.ReconstructPath(Depot, new Location(truckOrders.First().x, truckOrders.First().y, 0), astar.cameFrom);
            truckPaths.Add(path);

            for (int i = 0; i < truckOrders.Count - 1; i++)
            {
                astar = new AStarSearch(groundGrid,
                                        new Location(truckOrders[i].x, truckOrders[i].y, 0),
                                        new Location(truckOrders[i + 1].x, truckOrders[i + 1].y, 0));
                path = astar.ReconstructPath(new Location(truckOrders[i].x, truckOrders[i].y, 0),
                                             new Location(truckOrders[i + 1].x, truckOrders[i + 1].y, 0),
                                             astar.cameFrom);
                truckPaths.Add(path);
            }

            astar = new AStarSearch(groundGrid, new Location(truckOrders.Last().x, truckOrders.Last().y, 0), Depot);
            path  = astar.ReconstructPath(new Location(truckOrders.Last().x, truckOrders.Last().y, 0), Depot, astar.cameFrom);
            truckPaths.Add(path);

            truckStatusUpdate(truckPaths);
        }
コード例 #2
0
ファイル: Vehicle.cs プロジェクト: romanzedd/FSTSP
        public static List <Location> simpleRoute(SquareGrid grid, Location start, Location finish)
        {
            List <Location> path  = new List <Location>();
            AStarSearch     astar = new AStarSearch(grid, start, finish);

            path = astar.ReconstructPath(start, finish, astar.cameFrom);

            return(path);
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: romanzedd/FSTSP
        private void doDrone(List <Order> droneOrders)
        {
            List <List <Location> > dronePaths = new List <List <Location> >();

            foreach (var order in droneOrders)
            {
                List <Location> path  = new List <Location>();
                AStarSearch     astar = new AStarSearch(grid, Depot, new Location(order.x, order.y, 0));
                path = astar.ReconstructPath(Depot, new Location(order.x, order.y, 0), astar.cameFrom);
                var returnPath = path;
                returnPath.Reverse();
                path.AddRange(returnPath);
                dronePaths.Add(path);
            }

            droneStatusUpdate(dronePaths);
        }
コード例 #4
0
        public static string[] DrawGrid(SquareGrid grid, AStarSearch astar, Location start, Location goal)
        {
            string[] output = new string[4];
            // Печать массива cameFrom
            for (int z = 0; z < 4; z++)
            {
                for (var y = 0; y < 41; y++)
                {
                    for (var x = 0; x < 41; x++)
                    {
                        Location id  = new Location(x, y, z);
                        Location ptr = id;
                        if (!astar.cameFrom.TryGetValue(id, out ptr))
                        {
                            ptr = id;
                        }
                        if (start.x == x && start.y == y && start.z == z) /*Console.Write("\u2191 ");*/ x {
                            ++; output[z] += "S";
                        }
                        if (goal.x == x && goal.y == y && goal.z == z) /*Console.Write("\u2191 ");*/ x {
                            ++; output[z] += "F";
                        }

                        if (grid.walls.Contains(id)) /*Console.Write("##");*/ output {