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)); }
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)); }
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)); }
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)); }
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)); }
public override Object execute(RectangleAgent executor) { executor.MorphDown(); return(null); }
public override Object execute(RectangleAgent executor) { executor.NoAction(); return(null); }
public override Object execute(RectangleAgent executor) { executor.MoveRight(); return(null); }
public abstract Object execute(RectangleAgent executor);
public override Object execute(RectangleAgent executor) { executor.deleteDiamond(node); return(null); }
public override Object execute(RectangleAgent executor) { executor.MoveToPosition(x, move); return(null); }
public override Object execute(RectangleAgent executor) { executor.catchNextDiamond(node); return(null); }
public override Object execute(RectangleAgent executor) { return(executor.getCheapestPath()); }
public SquareWorldModel(RectangleAgent agent) : base() { platformManager = new SquarePlatformManager(this); this.agent = agent; }