diff --git a/src/othello/Main.java b/src/othello/Main.java index 4cb0a12..26e58b3 100644 --- a/src/othello/Main.java +++ b/src/othello/Main.java @@ -10,14 +10,14 @@ public class Main { int p1 = 1, p2 = 2; int[][] board = initialize(p1, p2); State game = new State(board, p1, p2,0,0); - while(!game.isOver()) { + //while(!game.isOver()) { int player = game.getCurrentPlayer(); - } + //} ArrayList a = new ArrayList(); a.add(new Point(3,3)); System.out.println(game.getMove(p1).toString()); - System.out.println(a.get(0).toString()); + //System.out.println(a.get(0).toString()); } public static int[][] initialize(int p1, int p2){ diff --git a/src/othello/State.java b/src/othello/State.java index fa96888..81a029e 100644 --- a/src/othello/State.java +++ b/src/othello/State.java @@ -26,7 +26,7 @@ public class State { } public ArrayList getMove(int player) { - ArrayList moves = null; + ArrayList moves = new ArrayList(); // Clonage // Parcours du plateau de jeu @@ -34,15 +34,12 @@ public class State { for (int j=0; j= 0) && (i+k < 7 ) && (j+l >= 0) && (j+l < 7 ) ) { - System.out.println("jadd"); + // Si une place libre est trouvée elle est ajoutée à la liste de coups + if ( ((i+k >= 0) && (i+k < 7 )) && ((j+l >= 0) && (j+l < 7 )) && (this.board[i+k][j+l]==0)) { moves.add(new Point(i+k, j+l)); } }