Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'origin/master'
  • Loading branch information
top13001 committed May 1, 2016
2 parents 4b0925d + f1dd4c9 commit 49ca835
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
8 changes: 8 additions & 0 deletions src/controller/GameConstants.java
Expand Up @@ -19,4 +19,12 @@ public class GameConstants {
public static final boolean MOB = true;
public static final boolean PIECE_DIFFERENTIAL = true;

/* Heuristic parameter weights */
public static final int APEX_WEIGHT = 2;
public static final int BACK_WEIGHT = 2;
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;

}
30 changes: 19 additions & 11 deletions src/model/Board.java
Expand Up @@ -422,8 +422,8 @@ public class Board {
}

public boolean isActive(Piece piece) {
ArrayList<Move> jumpFrontier = this.generateJumpMovesForPiece(piece);
if (piece == null) return false;
ArrayList<Move> jumpFrontier = this.generateJumpMovesForPiece(piece);
return jumpFrontier.size() != 0;
}

Expand Down Expand Up @@ -503,15 +503,23 @@ public class Board {
return 0;
}

/**
* "The parameter is credited with 1 for each square
* to which the active side could move one or more pieces in
* the normal fashion, disregarding the fact that jump moves
* may or may not be available.
* @param color
* @return
*/
public int mobHeuristic(Color color) {

return 0;
ArrayList<Move> moves = this.generateAllMoves(color);
return moves.size();
}

/**
* The parameter is credited with 1 for each of the
* "The parameter is credited with 1 for each of the
* following squares: 11, 12, 15, 16, 20, 21, 24, and 25
* which is occupied by a passive king.
* which is occupied by a passive king."
* @param color
* @return
*/
Expand All @@ -530,22 +538,22 @@ public class Board {
/* Kings are weighted more, so we count for them twice */
int heuristic = 0;
if (GameConstants.PIECE_DIFFERENTIAL) {
heuristic += pieceDifferentialHeuristic(color);
heuristic += pieceDifferentialHeuristic(color)*GameConstants.PIECE_DIFFERENTIAL_WEIGHT;
}
if (GameConstants.APEX) {
heuristic += apexHeuristic(color);
heuristic += apexHeuristic(color)*GameConstants.APEX_WEIGHT;
}
if (GameConstants.BACK) {
heuristic += backHeuristic(color);
heuristic += backHeuristic(color)*GameConstants.BACK_WEIGHT;
}
if (GameConstants.CENT) {
heuristic += centHeuristic(color);
heuristic += centHeuristic(color)*GameConstants.CENT_WEIGHT;
}
if (GameConstants.MOB) {
heuristic += mobHeuristic(color);
heuristic += mobHeuristic(color)*GameConstants.MOB_WEIGHT;
}
if (GameConstants.KCENT) {
heuristic += kcentHeuristic(color);
heuristic += kcentHeuristic(color)*GameConstants.KCENT_WEIGHT;
}

return heuristic;
Expand Down

0 comments on commit 49ca835

Please sign in to comment.