diff --git a/src/controller/GameConstants.java b/src/controller/GameConstants.java index 7bba8eb..e638099 100644 --- a/src/controller/GameConstants.java +++ b/src/controller/GameConstants.java @@ -17,6 +17,7 @@ public class GameConstants { public static final boolean CENT = true; public static final boolean KCENT = true; public static final boolean MOB = true; + public static final boolean POLE = true; public static final boolean PIECE_DIFFERENTIAL = true; /* Heuristic parameter weights */ @@ -25,6 +26,7 @@ public class GameConstants { public static final int CENT_WEIGHT = 2; public static final int KCENT_WEIGHT = 2; public static final int MOB_WEIGHT = 1; - public static final int PIECE_DIFFERENTIAL_WEIGHT = 2; + public static final int POLE_WEIGHT = 2; + public static final int PIECE_DIFFERENTIAL_WEIGHT = 3; } diff --git a/src/model/Board.java b/src/model/Board.java index 9aa2f20..a7f15de 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -410,9 +410,9 @@ public class Board { int row = piece.getLocation().row; int col = piece.getLocation().column; boolean up = row > 0, - down = row < GameConstants.BOARD_SIZE, + down = row < GameConstants.BOARD_SIZE - 1, left = col > 0, - right = row < GameConstants.BOARD_SIZE; + right = col < GameConstants.BOARD_SIZE - 1; if (up && left && this.representation[row-1][col-1] == null) ++num; if (up && right && this.representation[row-1][col+1] == null) ++num; if (down && left && this.representation[row+1][col-1] == null) ++num; @@ -504,6 +504,30 @@ public class Board { return sum; } + /** + * "The parameter is credited with 1 for + * each passive man that is completely + * surrounded by empty squares." + * @param color + * @return + */ + public int poleHeuristic(Color color) { + int sum = 0; + for (int i = 0; i < GameConstants.BOARD_SIZE; ++i) { + for (int j = 0; j < GameConstants.BOARD_SIZE; ++j) { + Piece p = this.representation[i][j]; + if (p != null) { + if (p.getType() == Type.NORMAL && + !isActive(p) && + emptySquaresSurrounding(p) == 4) { + ++sum; + } + } + } + } + return sum; + } + public int getHeuristic(Color color) { /* Kings are weighted more, so we count for them twice */ int heuristic = 0; @@ -522,6 +546,9 @@ public class Board { if (GameConstants.MOB) { heuristic += mobHeuristic(color)*GameConstants.MOB_WEIGHT; } + if (GameConstants.POLE) { + heuristic += poleHeuristic(color)*GameConstants.POLE_WEIGHT; + } if (GameConstants.KCENT) { heuristic += kcentHeuristic(color)*GameConstants.KCENT_WEIGHT; }