diff --git a/src/CheckersGameState2.java b/src/CheckersGameState2.java index e468788..37bbf2b 100644 --- a/src/CheckersGameState2.java +++ b/src/CheckersGameState2.java @@ -17,10 +17,13 @@ public class CheckersGameState2 implements CheckersGameState { public static void main(String args[]) { CheckersGameState2 state = new CheckersGameState2(); state.printState(); - List actions = state.actions(); - for(Move move : actions) { - System.out.println((Move2)move); - state.result(move).printState(); + for(int i = 0; i<6; i++){ + List actions = state.actions(); + for(Move move : actions) { + System.out.println((Move2)move+" ~~ "+((Move2)move).dest); + } + state = (CheckersGameState2)state.result(actions.get(0)); + state.printState(); } } @@ -119,42 +122,28 @@ public class CheckersGameState2 implements CheckersGameState { ArrayList moves = new ArrayList(); int piece = board[starting]; int[] neighbors = neighbors(current); + int beg, end; if(piece == 1) { - for(int i = 0; i<2; i++) { - if(neighbors[i] != -1 && isEnemy(board[neighbors[i]])) { - int next = neighbors(neighbors[i])[i]; - if(board[next] == 0) { - int [] newPath = Arrays.copyOf(path, path.length+1); - int c = capture == -1 ? neighbors[i] : capture; - moves.add(new Move2(newPath, c)); - moves.addAll(findJumpMoves(starting, next, newPath,c)); - } - } - } + beg = 0; + end = 2; } else if(piece == 2) { - for(int i = 2; i<4; i++) { - if(neighbors[i] != -1 && isEnemy(board[neighbors[i]])) { - int next = neighbors(neighbors[i])[i]; - if(board[next] == 0) { - int [] newPath = Arrays.copyOf(path, path.length+1); - int c = capture == -1 ? neighbors[i] : capture; - moves.add(new Move2(newPath, c)); - moves.addAll(findJumpMoves(starting, next, newPath, c)); - } - } - } + beg = 2; + end = 4; } else { - for(int i = 0; i<4; i++) { - if(neighbors[i] != -1 && isEnemy(board[neighbors[i]])) { - int next = neighbors(neighbors[i])[i]; - if(board[next] == 0) { - int [] newPath = Arrays.copyOf(path, path.length+1); - int c = capture == -1 ? neighbors[i] : capture; - moves.add(new Move2(newPath, c)); - moves.addAll(findJumpMoves(starting, next, newPath, c)); - } + beg = 0; + end = 4; + } + for(int i = beg; i