Beispiel #1
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);
    }
  }