Ejemplo n.º 1
0
 private int controlBorders(int hv) {
   int heurVal = hv;
   for (int row = 2; row < Board.SIZE - 3; row++) {
     if (board.getField()[row][0] == myTile) {
       heurVal += 5;
     }
     if (board.getField()[row][Board.SIZE - 1] == myTile) {
       heurVal += 5;
     }
   }
   for (int col = 2; col < Board.SIZE - 3; col++) {
     if (board.getField()[0][col] == myTile) {
       heurVal += 5;
     }
     if (board.getField()[Board.SIZE - 1][col] == myTile) {
       heurVal += 5;
     }
   }
   return heurVal;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 private int controlCorners(int hv) {
   int heurVal = hv;
   if (board.getField()[0][0] == Tile.EMPTY) {
     if (board.getField()[0][1] == myTile) {
       heurVal -= 10;
     }
     if (board.getField()[1][1] == myTile) {
       heurVal -= 10;
     }
     if (board.getField()[1][0] == myTile) {
       heurVal -= 10;
     }
   } else if (board.getField()[0][0] == myTile) {
     heurVal += 50;
   }
   if (board.getField()[Board.SIZE - 1][0] == Tile.EMPTY) {
     if (board.getField()[Board.SIZE - 1][1] == myTile) {
       heurVal -= 10;
     }
     if (board.getField()[Board.SIZE - 2][1] == myTile) {
       heurVal -= 10;
     }
     if (board.getField()[Board.SIZE - 2][0] == myTile) {
       heurVal -= 10;
     }
   } else if (board.getField()[Board.SIZE - 1][0] == myTile) {
     heurVal += 50;
   }
   if (board.getField()[0][Board.SIZE - 1] == Tile.EMPTY) {
     if (board.getField()[1][Board.SIZE - 1] == myTile) {
       heurVal -= 10;
     }
     if (board.getField()[0][Board.SIZE - 2] == myTile) {
       heurVal -= 10;
     }
     if (board.getField()[1][Board.SIZE - 2] == myTile) {
       heurVal -= 10;
     }
   } else if (board.getField()[0][Board.SIZE - 1] == myTile) {
     heurVal += 50;
   }
   if (board.getField()[Board.SIZE - 1][Board.SIZE - 1] == Tile.EMPTY) {
     if (board.getField()[Board.SIZE - 2][Board.SIZE - 1] == myTile) {
       heurVal -= 10;
     }
     if (board.getField()[Board.SIZE - 1][Board.SIZE - 2] == myTile) {
       heurVal -= 10;
     }
     if (board.getField()[Board.SIZE - 2][Board.SIZE - 2] == myTile) {
       heurVal -= 10;
     }
   } else if (board.getField()[Board.SIZE - 1][Board.SIZE - 1] == myTile) {
     heurVal += 50;
   }
   return heurVal;
 }