From cd2cfe73fa8303925a7af3d14c870496cf433f29 Mon Sep 17 00:00:00 2001 From: aah13002 Date: Sat, 30 Apr 2016 22:08:00 -0400 Subject: [PATCH] Added skeleton for different heuristics parameters. Added a function to map between Samuel's piece numbering to a Location on our board --- src/model/Board.java | 24 ++++++++++++++++++++++++ src/test/BoardTest.java | 10 ++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/model/Board.java b/src/model/Board.java index 93aecae..ecc7c2d 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -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; diff --git a/src/test/BoardTest.java b/src/test/BoardTest.java index 8dea1b5..453e7e7 100755 --- a/src/test/BoardTest.java +++ b/src/test/BoardTest.java @@ -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(); } }