Skip to content

Commit

Permalink
Added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sas12028 committed Apr 4, 2017
1 parent 94d335a commit 1f29842
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/CheckersGameState3.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import java.util.List;
import java.util.LinkedList;

public class CheckersGameState3{
public class CheckersGameState3 implements CheckersGameState{

int player;
int[] board;
Expand Down Expand Up @@ -70,7 +70,7 @@ else if(leading){
return b;
}

String player(){
public String player(){
if(this.player == 1){
return "black";
}
Expand Down Expand Up @@ -224,7 +224,7 @@ private void calculate_jumps(String path, int[] b, int orig, int delta1, int del
}


CheckersGameState3 result(Move x){
public CheckersGameState3 result(Move x){
int[] newState = this.board.clone();
newState[x.destination()] = this.board[x.source()];
newState[x.source()] = 0;
Expand All @@ -242,7 +242,7 @@ else if(x.destination() > 30 && this.player == 1){
return new CheckersGameState3(1 - this.player, newState);
}

void printState(){
public void printState(){
boolean leading = false;
int printed = 0;
for(int i = 0; i < this.board.length; i++){
Expand Down
31 changes: 22 additions & 9 deletions src/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ public class Test{

public static void main(String[] args){
String[] b = {"-", "b", "-", "b", "-", "b", "-", "b",
"-", "-", "-", "-", "B", "-", "b", "-",
"-", "w", "-", "w", "-", "b", "-", "-",
"-", "-", "-", "-", "b", "-", "w", "-",
"b", "-", "b", "-", "b", "-", "b", "-",
"-", "b", "-", "b", "-", "b", "-", "b",
"-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-",
"w", "-", "w", "-", "w", "-", "w", "-",
"-", "w", "-", "-", "-", "w", "-", "w",
"-", "w", "-", "w", "-", "w", "-", "w",
"w", "-", "w", "-", "w", "-", "w", "-"};

String[] b2 = {"-", "-", "-", "b", "-", "b", "-", "b",
"b", "-", "w", "-", "b", "-", "b", "-",
"-", "b", "-", "B", "-", "b", "-", "b",
Expand All @@ -19,6 +20,7 @@ public static void main(String[] args){
"w", "-", "w", "-", "w", "-", "w", "-",
"-", "w", "-", "-", "-", "w", "-", "w",
"w", "-", "w", "-", "w", "-", "w", "-"};

String[] b3 = {"-", "-", "-", "b", "-", "b", "-", "b",
"b", "-", "b", "-", "b", "-", "b", "-",
"-", "b", "-", "w", "-", "b", "-", "b",
Expand All @@ -29,11 +31,22 @@ public static void main(String[] args){
"-", "-", "w", "-", "w", "-", "w", "-"};


CheckersGameState3 s2 = new CheckersGameState3(2, b3);
s2.printState();
System.out.println(s2.actions().get(0));
s2.result(s2.actions().get(0)).printState();
for(Move m: s2.actions()){
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(2, b3);
printMoves(s1);
printMoves(s2);
printMoves(s3);
printMoves(s4);
printMoves(s5);
s5.result(s5.actions().get(0)).printState();
}

static void printMoves(CheckersGameState s){
s.printState();
for(Move m: s.actions()){
System.out.println(m);
}
}
Expand Down

0 comments on commit 1f29842

Please sign in to comment.