From 17db265925a12d967e3dc2b6a4b71f943b7291b9 Mon Sep 17 00:00:00 2001 From: Antonin Boyon <22009544@etu.unicaen.fr> Date: Wed, 10 Feb 2021 10:21:26 +0100 Subject: [PATCH] =?UTF-8?q?m=C3=A9thode=20de=20clonage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/othello/Main.java | 6 +++--- src/othello/State.java | 11 ++++------- 2 files changed, 7 insertions(+), 10 deletions(-) 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)); } }