diff --git a/src/CheckersGameState3.java b/src/CheckersGameState3.java index a078802..4b89228 100644 --- a/src/CheckersGameState3.java +++ b/src/CheckersGameState3.java @@ -1,7 +1,7 @@ import java.util.List; import java.util.LinkedList; -public class CheckersGameState3{ +public class CheckersGameState3 implements CheckersGameState{ int player; int[] board; @@ -70,7 +70,7 @@ else if(leading){ return b; } - String player(){ + public String player(){ if(this.player == 1){ return "black"; } @@ -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; @@ -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++){ diff --git a/src/Test.java b/src/Test.java index cb03b95..e12304d 100644 --- a/src/Test.java +++ b/src/Test.java @@ -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", @@ -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", @@ -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); } }