示例#1
0
        public int UseMCTS(int x, int centerY)
        {
            Log.LogInformation("Driver MCTS - MCTS start");

            int s = 1;

            while (!RectangleAgent.obstacleOpenSpace[centerY + s, x])
            {
                s++;
            }
            Node square = new Node(x, centerY + s - 1, false);

            this.nodes[0] = square;
            int y = square.getY();

            deleteCollectedDiamonds();

            RectangleAgent.nodes = this.nodes;
            RectangleAgent.CreateEdgesAndAdjacencyMatrix();
            this.adjacencyMatrix = RectangleAgent.adjacencyMatrix;
            this.directionMap    = RectangleAgent.directionMap;

            MCTS         driverMCTS = new MCTS(this.nodes, this.adjacencyMatrix, RectangleAgent.nCollectiblesLeft, 2000);
            Queue <Node> newRoute   = driverMCTS.Run();

            this.route = RectangleAgent.ClearRoute(newRoute.ToArray(), driverMCTS.outputNodeIndex);

            return(recalcNextNodes("MCTS", x, y));
        }
示例#2
0
        private int UseGreedyGoalAStar(int x, int centerY)
        {
            Log.LogInformation("Driver Greedy Goal AStar - Greedy Goal AStar start");

            int s = 1;

            while (!RectangleAgent.obstacleOpenSpace[centerY + s, x])
            {
                s++;
            }
            Node square = new Node(x, centerY + s - 1, false);

            this.nodes[0] = square;
            int y = square.getY();

            deleteCollectedDiamonds();

            RectangleAgent.nodes = this.nodes;
            RectangleAgent.CreateEdgesAndAdjacencyMatrix();
            this.adjacencyMatrix = RectangleAgent.adjacencyMatrix;
            this.directionMap    = RectangleAgent.directionMap;

            this.route = RectangleAgent.calcShortestRouteAStar();

            return(recalcNextNodes("Greedy Goal AStar", x, y));
        }
示例#3
0
        private int UseSubgoalAStar(int x, int centerY)
        {
            Log.LogInformation("Driver Subgoal AStar - Subgoal AStar start");

            int s = 1;

            while (!RectangleAgent.obstacleOpenSpace[centerY + s, x])
            {
                s++;
            }
            Node square = new Node(x, centerY + s - 1, false);

            this.nodes[0] = square;
            int y = square.getY();

            deleteCollectedDiamonds();

            List <int> diamondNodes = new List <int>();

            for (int n = 0; n < nodes.Count; n++)
            {
                if (nodes[n].getDiamond())
                {
                    diamondNodes.Add(n);
                }
            }

            RectangleAgent.nodes = this.nodes;
            RectangleAgent.CreateEdgesAndAdjacencyMatrix();
            this.adjacencyMatrix = RectangleAgent.adjacencyMatrix;
            this.directionMap    = RectangleAgent.directionMap;

            SubgoalAStar sgAstar = new SubgoalAStar(0, diamondNodes, 2000, 0);

            route = sgAstar.Run();
            int diamondsToCollect = diamondNodes.Count - 1;

            while (route == null)
            {
                sgAstar = new SubgoalAStar(0, diamondNodes, 2000, diamondsToCollect);
                route   = sgAstar.Run();
                diamondsToCollect--;
                if (diamondsToCollect == 0)
                {
                    route = new Queue <Node>();
                }
            }

            return(recalcNextNodes("Subgoal AStar", x, y));
        }
示例#4
0
        public int UseMCTSWithAStar(int x, int centerY)
        {
            Log.LogInformation("Driver MCTS ASTAR - MCTS ASTAR start");

            int s = 1;

            while (!RectangleAgent.obstacleOpenSpace[centerY + s, x])
            {
                s++;
            }
            Node square = new Node(x, centerY + s - 1, false);

            this.nodes[0] = square;
            int y = square.getY();

            deleteCollectedDiamonds();

            RectangleAgent.nodes = this.nodes;
            RectangleAgent.CreateEdgesAndAdjacencyMatrix();
            this.adjacencyMatrix = RectangleAgent.adjacencyMatrix;
            this.directionMap    = RectangleAgent.directionMap;

            MCTS         driverMCTS = new MCTS(this.nodes, this.adjacencyMatrix, RectangleAgent.nCollectiblesLeft, 2000);
            Queue <Node> newRoute   = driverMCTS.Run();

            this.route = RectangleAgent.ClearRoute(newRoute.ToArray(), driverMCTS.outputNodeIndex);

            //AStar
            Node[]      routeAsArray = this.route.ToArray();
            List <Node> diamondNodes = new List <Node>();

            for (int n = 0; n < routeAsArray.Length; n++)
            {
                if (routeAsArray[n].getDiamond() && !diamondNodes.Contains(routeAsArray[n]))
                {
                    diamondNodes.Add(routeAsArray[n]);
                }
            }

            this.route = RectangleAgent.calcShortestRouteWithDiamondOrderAStar(diamondNodes);
            //AStar end

            return(recalcNextNodes("MCTS ASTAR", x, y));
        }
示例#5
0
        private int UseYHeuristicAStar(int x, int centerY)
        {
            Log.LogInformation("Driver Y-Heuristic AStar - Y-Heuristic AStar start");

            int s = 1;

            while (!RectangleAgent.obstacleOpenSpace[centerY + s, x])
            {
                s++;
            }
            Node square = new Node(x, centerY + s - 1, false);

            this.nodes[0] = square;
            int y = square.getY();

            deleteCollectedDiamonds();

            List <Node> diamondNodes = new List <Node>();

            for (int n = 0; n < nodes.Count; n++)
            {
                if (nodes[n].getDiamond())
                {
                    diamondNodes.Add(nodes[n]);
                }
            }

            RectangleAgent.nodes = this.nodes;
            RectangleAgent.CreateEdgesAndAdjacencyMatrix();
            this.adjacencyMatrix = RectangleAgent.adjacencyMatrix;
            this.directionMap    = RectangleAgent.directionMap;

            diamondNodes = RectangleAgent.calcDiamondOrder(diamondNodes);
            this.route   = RectangleAgent.calcShortestRouteWithDiamondOrderAStar(diamondNodes);

            return(recalcNextNodes("Y-Heuristic AStar", x, y));
        }
示例#6
0
 public override Object execute(RectangleAgent executor)
 {
     executor.MorphDown();
     return(null);
 }
示例#7
0
 public override Object execute(RectangleAgent executor)
 {
     executor.NoAction();
     return(null);
 }
示例#8
0
 public override Object execute(RectangleAgent executor)
 {
     executor.MoveRight();
     return(null);
 }
示例#9
0
 public abstract Object execute(RectangleAgent executor);
示例#10
0
 public override Object execute(RectangleAgent executor)
 {
     executor.deleteDiamond(node);
     return(null);
 }
示例#11
0
 public override Object execute(RectangleAgent executor)
 {
     executor.MoveToPosition(x, move);
     return(null);
 }
示例#12
0
 public override Object execute(RectangleAgent executor)
 {
     executor.catchNextDiamond(node);
     return(null);
 }
示例#13
0
 public override Object execute(RectangleAgent executor)
 {
     return(executor.getCheapestPath());
 }
示例#14
0
 public SquareWorldModel(RectangleAgent agent)
     : base()
 {
     platformManager = new SquarePlatformManager(this);
     this.agent      = agent;
 }