Skip to content

Commit

Permalink
Fix bug in result
Browse files Browse the repository at this point in the history
  • Loading branch information
sas12028 committed Apr 4, 2017
1 parent f989e92 commit 0d2954c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/CheckersGameState3.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@ private void calculate_jumps(String path, int[] b, int orig, int delta1, int del

public CheckersGameState3 result(Move x){
int[] newState = this.board.clone();
newState[x.destination()] = this.board[x.source()];
int type = this.board[x.source()];
newState[x.source()] = 0;
newState[x.destination()] = type;
if(x.destination() < 4 && this.player == 2){
newState[x.destination()] = 4;
}
Expand Down
15 changes: 14 additions & 1 deletion src/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static void main(String[] args){

String[] b2 = {"-", "-", "-", "b", "-", "b", "-", "b",
"b", "-", "w", "-", "b", "-", "b", "-",
"-", "b", "-", "B", "-", "b", "-", "b",
"-", "-", "-", "B", "-", "-", "-", "b",
"-", "-", "w", "-", "w", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-",
"w", "-", "w", "-", "w", "-", "w", "-",
Expand All @@ -30,13 +30,24 @@ public static void main(String[] args){
"-", "w", "-", "-", "-", "w", "-", "w",
"-", "-", "w", "-", "w", "-", "w", "-"};

String[] b4 = {"-", "-", "-", "b", "-", "b", "-", "b",
"b", "-", "-", "-", "b", "-", "b", "-",
"-", "-", "-", "B", "-", "-", "-", "b",
"-", "-", "w", "-", "w", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-",
"w", "-", "w", "-", "w", "-", "w", "-",
"-", "w", "-", "-", "-", "w", "-", "w",
"w", "-", "w", "-", "w", "-", "w", "-"};



CheckersGameState s1 = new CheckersGameState3(1, b);
CheckersGameState s2 = new CheckersGameState3(2, b);
CheckersGameState s3 = new CheckersGameState3(1, b2);
CheckersGameState s4 = new CheckersGameState3(2, b2);
CheckersGameState s5 = new CheckersGameState3(1, b3);
CheckersGameState s6 = new CheckersGameState3(2, b3);
CheckersGameState s7 = new CheckersGameState3(1, b4);
printMoves(s1);
printMoves(s2);
printMoves(s3);
Expand All @@ -45,6 +56,8 @@ public static void main(String[] args){
s5.result(s5.actions().get(0)).printState();
printMoves(s6);
s6.result(s6.actions().get(0)).printState();
printMoves(s7);
s7.result(s7.actions().get(0)).printState();
}

static void printMoves(CheckersGameState s){
Expand Down

0 comments on commit 0d2954c

Please sign in to comment.