Exemple #1
0
 public int extraHV() {
   int heurVal = board.getPossiblePositions(myTile).size() * 3;
   if (heurVal == 0 && board.getPossiblePositions(myTile.getOpposite()).isEmpty()) {
     int myCount = 0, otherCount = 0;
     for (int row = 0; row < Board.SIZE; row++) {
       for (int col = 0; col < Board.SIZE; col++) {
         if (board.getField()[row][col] == myTile) {
           myCount++;
         } else if (board.getField()[row][col] == myTile.getOpposite()) {
           otherCount++;
         }
       }
       if (myCount - otherCount < 0) {
         return -10000;
       } else if (myCount - otherCount > 0) {
         return 10000;
       }
     }
   }
   heurVal += controlCorners(heurVal) + controlBorders(heurVal);
   return heurVal;
 }
Exemple #2
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()));
             }
           }
         }
       }
     }
   }
 }