Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added skeleton for different heuristics parameters. Added a function …
…to map between Samuel's piece numbering to a Location on our board
  • Loading branch information
Aaron committed May 1, 2016
1 parent c84c9bb commit cd2cfe7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/model/Board.java
Expand Up @@ -397,6 +397,30 @@ public class Board {
(whiteHeuristic - blackHeuristic));
}

public Location samuelMapping(int k) {
int augmented = (32 - k) * 2;
int row = augmented / GameConstants.BOARD_SIZE;
int col = augmented % GameConstants.BOARD_SIZE;
if (row % 2 == 0) ++col;
return new Location(row, col);
}

public int emptySquaresSurrounding(Piece piece) {
int num = 0;
int row = piece.getLocation().row;
int col = piece.getLocation().column;
boolean up = row > 0,
down = row < GameConstants.BOARD_SIZE,
left = col > 0,
right = row < GameConstants.BOARD_SIZE;
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;
if (down && right && this.representation[row+1][col+1] == null) ++num;

return num;
}

public int apexHeuristic(Color color) {

return 0;
Expand Down
10 changes: 8 additions & 2 deletions src/test/BoardTest.java
Expand Up @@ -13,10 +13,16 @@ public class BoardTest {
Board b = new Board();
b.print();
}

public static void samuelMappingTest() {
Board b = new Board();
for(int i = 1; i <= 32; ++i) {
System.out.println(i + " : " + b.samuelMapping(i));
}
}

public static void main(String[]args) {
printTest();
movementTest();
samuelMappingTest();
}
}

0 comments on commit cd2cfe7

Please sign in to comment.