예제 #1
0
 public int simulateGame(GameStateInterface gs) {
   GameStateInterface simGs = gs.copy();
   if (simulateJustLastLife) {
     simGs.setLastLife();
   }
   Game game = new Game(simGs, null, new RandomNonReverseMsPacMan(), ghosts);
   try {
     return game.run(0, maxSimulationTicks);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return 0;
 }
예제 #2
0
  public void expand() {

    Node[] possibles = new Node[4];
    int possCount = 0;
    for (Node n : gameState.getPacman().current.adj) {
      if (!n.equals(prev)) {
        possibles[possCount++] = n;
      }
    }

    int nActions = possCount;
    children = new TreeNode[nActions];
    for (int i = 0; i < nActions; i++) {
      Node target = possibles[i];
      GameStateInterface nextGs = gameState.copy();
      nextGs.next(
          Utilities.getWrappedDirection(gameState.getPacman().current, target, gameState.getMaze()),
          ghosts.getActions(gameState));
      children[i] = new TreeNode(nextGs, gameState.getPacman().current);
    }
  }