Пример #1
0
      public NodeIterator(Node start, int n) {

        for (int i = -2; i <= 2; i++) {
          for (int j = -2; j <= 2; j++) {

            Board settingClone = new BoardImpl((BoardImpl) setting);
            Player moverClone = new PlayerImpl(owner);

            settingClone.getPawn(moverClone, settingClone).setSquare(square);

            MovePawn tentative =
                new MovePawnImpl(
                    square.getCol() + j, square.getRow() + i, moverClone, settingClone);

            if (tentative.isValid()) {

              nextList.add(
                  new Node(
                      new SquareImpl(square.getCol() + j, square.getRow() + i),
                      n + 1,
                      moverClone,
                      start));
            }
          }
        }

        backer = nextList.iterator();
      }
Пример #2
0
    private void populate() {
      // populate with MovePawns
      for (int i = -2; i <= 2; i++) {
        for (int j = -2; j <= 2; j++) {
          Square tmp = setting.getPawn(mover, setting).getSquare();
          Board settingClone = new BoardImpl((BoardImpl) setting);
          Player moverClone = new PlayerImpl(mover);
          MovePawn tentative =
              new MovePawnImpl(tmp.getCol() + j, tmp.getRow() + i, moverClone, settingClone);

          if (tentative.isValid()) {

            pawnBackerList.add(new StateImpl(settingClone, moverClone, tentative));
          }
        }
      }

      for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
          Board settingClone = new BoardImpl((BoardImpl) setting);
          Player moverClone = new PlayerImpl(mover);

          PlaceWall vTentative = new PlaceWallImpl(i, j, Wall.VERTICAL, moverClone, settingClone);

          settingClone = new BoardImpl((BoardImpl) setting);
          moverClone = new PlayerImpl(mover);

          PlaceWall hTentative = new PlaceWallImpl(i, j, Wall.HORIZONTAL, moverClone, settingClone);

          if (vTentative.isValid()) {
            wallBackerList.add(new StateImpl(settingClone, moverClone, vTentative));
          }

          if (hTentative.isValid()) {
            wallBackerList.add(new StateImpl(settingClone, moverClone, hTentative));
          }
        }
      }
    }