Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }