Example #1
0
 public void setChilds() {
   int myRow, myCol;
   for (int row = 0; row < Board.SIZE; row++) {
     for (int col = 0; col < Board.SIZE; col++) {
       if (board.getTile(row, col) == myTile.getOpposite()) {
         for (Direction dir : Direction.values()) {
           myRow = row + dir.getRow();
           myCol = col + dir.getCol();
           if (!(myRow < 0 || myCol < 0 || myRow >= Board.SIZE || myCol >= Board.SIZE)
               && board.getTile(myRow, myCol) == Tile.EMPTY) {
             if (board.possibleChange(myRow, myCol, myTile, dir.getOpposite())) {
               childs.add(
                   getNewChild(
                       board.putTile(myRow, myCol, myTile.getOpposite()),
                       new Position(myRow, myCol),
                       myTile.getOpposite()));
             }
           }
         }
       }
     }
   }
 }