Skip to content

Commit

Permalink
Evaluation takes into account middle blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
vaquierm committed Mar 26, 2019
1 parent 73b8f03 commit 26bd678
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 38 deletions.
74 changes: 36 additions & 38 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions src/student_player/CustomPentagoBoardState.java
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ private int computePatternValuesForPiece(Piece piece, boolean offensiveMode) {
0b000000001, 0b000000000, 0b000000000, 0b100000000,
0b000000000, 0b000000100, 0b001000000, 0b000000000};

int[] twoEndsBitMasks = { 0b101000000, 0b000101000, 0b000000101, 0b100000100, 0b010000101, 0b001000001, 0b100000001, 0b001000100 };

int[] twoEndsBlockBitMasks = { 0b010000000, 0b000010000, 0b000000010, 0b000100000, 0b000010000, 0b000001000, 0b000010000, 0b000010000 };

int[][] patternPresent = new int[4][bitMasksForPairs.length];
int[][] patternPresentOpponent = new int[4][bitMasksForPairs.length];
int[][] antiPatternPresent = new int[4][bitMasksForAntiPairs.length];
Expand Down Expand Up @@ -577,6 +581,19 @@ private int computePatternValuesForPiece(Piece piece, boolean offensiveMode) {
}
}

// Check if there is any major blocks
for (int i = 0; i < twoEndsBitMasks.length; i++) {
for (int k = 0; k < 4; k++) {
// if the two pieces are in the corner and it is blocked that is worth points
if ((quadrantValues[k] & twoEndsBitMasks[i]) == twoEndsBitMasks[i] && (quadrantValuesOpponent[k] & twoEndsBlockBitMasks[i]) == twoEndsBlockBitMasks[i]) {
overallScore -= (offensiveMode) ? 3 : 6;
}
if ((quadrantValuesOpponent[k] & twoEndsBitMasks[i]) == twoEndsBitMasks[i] && (quadrantValues[k] & twoEndsBlockBitMasks[i]) == twoEndsBlockBitMasks[i]) {
overallScore += (offensiveMode) ? 3 : 6;
}
}
}

// Now that the patterns has been found, add bonus

// Horizontal pieces
Expand Down

0 comments on commit 26bd678

Please sign in to comment.