Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
john committed May 1, 2016
2 parents 09aecf4 + e4b23eb commit 0626ab0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/controller/Communication.java
Expand Up @@ -35,8 +35,8 @@ public class Communication {
ArrayList<Move> moves = new ArrayList<Move>();

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);
}
Expand All @@ -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(")");
Expand Down
1 change: 1 addition & 0 deletions src/controller/GameConstants.java
Expand Up @@ -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;
}
12 changes: 6 additions & 6 deletions src/test/CommunicationTest.java
Expand Up @@ -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<Move> 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";

Expand All @@ -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<Move> moves = new ArrayList<Move>();
Expand All @@ -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");
}
Expand Down

0 comments on commit 0626ab0

Please sign in to comment.