diff --git a/src/controller/Communication.java b/src/controller/Communication.java index 40fcd22..53c813a 100755 --- a/src/controller/Communication.java +++ b/src/controller/Communication.java @@ -35,8 +35,8 @@ public class Communication { ArrayList moves = new ArrayList(); for (int i = 0; i < moveIndexes.size() - 3; i+=2) { - Location from = new Location(moveIndexes.get(i), moveIndexes.get(i+1)); - Location to = new Location(moveIndexes.get(i+2), moveIndexes.get(i+3)); + Location from = new Location(GameConstants.BOARD_SIZE - 1 - moveIndexes.get(i), moveIndexes.get(i+1)); + Location to = new Location(GameConstants.BOARD_SIZE - 1 - moveIndexes.get(i+2), moveIndexes.get(i+3)); Move move = new Move(from, to); moves.add(move); } @@ -57,18 +57,18 @@ public class Communication { Move firstmove = moves.get(0); sb.append("("); - sb.append(firstmove.source.row); + sb.append(GameConstants.BOARD_SIZE - 1 - firstmove.source.row); sb.append(":"); sb.append(firstmove.source.column); sb.append("):("); - sb.append(firstmove.destination.row); + sb.append(GameConstants.BOARD_SIZE - 1 - firstmove.destination.row); sb.append(":"); sb.append(firstmove.destination.column); sb.append(")"); for (int i = 1; i < moves.size(); ++i) { Move move = moves.get(i); sb.append(":("); - sb.append(move.destination.row); + sb.append(GameConstants.BOARD_SIZE - 1 - move.destination.row); sb.append(":"); sb.append(move.destination.column); sb.append(")"); diff --git a/src/controller/GameConstants.java b/src/controller/GameConstants.java index f088570..381d95c 100644 --- a/src/controller/GameConstants.java +++ b/src/controller/GameConstants.java @@ -9,4 +9,5 @@ public class GameConstants { public static final Color USER_COLOR = Color.BLACK; public static final int MAX_PASSIVE_MOVES = 50; public static final int MAX_SEARCH_DEPTH = 7; + public static final int BOARD_SIZE = 8; } diff --git a/src/test/CommunicationTest.java b/src/test/CommunicationTest.java index 2f617d3..3a8eb34 100755 --- a/src/test/CommunicationTest.java +++ b/src/test/CommunicationTest.java @@ -21,16 +21,16 @@ public class CommunicationTest { /** * Input: "(0:0):(2:2):(4:0)" * - * Output: { Move( from=(0,0), to=(2,2) ), - * Move( from=(2,2), to=(4,0) ) } + * Output: { Move( from=(7,0), to=(5,2) ), + * Move( from=(5,2), to=(3,0) ) } */ public void stringToMoveTest() { String moveString = "(0:0):(2:2):(4:0)"; ArrayList moves = Communication.stringToMove(moveString); - Move move1 = new Move(new Location(0, 0), new Location(2, 2)); - Move move2 = new Move(new Location(2, 2), new Location(4, 0)); + Move move1 = new Move(new Location(7, 0), new Location(5, 2)); + Move move2 = new Move(new Location(5, 2), new Location(3, 0)); assert(moveExistsInSet(move1, moves) && moveExistsInSet(move2, moves)) : "FAILED: String --> Move"; @@ -41,7 +41,7 @@ public class CommunicationTest { * Input: { Move( from=(0,0), to=(2,2) ), * Move( from=(2,2), to=(4,0) ) } * - * Output: "(0:0):(2:2):(4:0)" + * Output: "(7:0):(5:2):(3:0)" */ public void moveToStringTest() { ArrayList moves = new ArrayList(); @@ -52,7 +52,7 @@ public class CommunicationTest { String moveString = Communication.moveToString(moves); - assert(moveString.equals("(0:0):(2:2):(4:0)")) : "PASSED: Move --> String"; + assert(moveString.equals("(7:0):(5:2):(3:0)")) : "PASSED: Move --> String"; System.out.println("PASSED: Move --> String"); }