From e675b8ae59b16044cf22d845773f23ebd05fbe56 Mon Sep 17 00:00:00 2001 From: Arthur <78031901+Arthur7770@users.noreply.github.com> Date: Wed, 10 Feb 2021 12:26:47 +0100 Subject: [PATCH] differencing jump and clone --- src/othello/State.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/othello/State.java b/src/othello/State.java index a15f3c2..70655da 100644 --- a/src/othello/State.java +++ b/src/othello/State.java @@ -38,15 +38,20 @@ public class State { for (int x = 0; x < this.board[y].length; x++) { if (this.board[y][x] == player) { // Recherche autour du pion du joueur courant - for (int deltaY = -2; deltaY < 3; deltaY++) { - for (int deltaX = -2; deltaX < 3; deltaX++) { + for (int deltaY = -1; deltaY < 2; deltaY++) { + for (int deltaX = -1; deltaX < 2; deltaX++) { // La position du pion trouv� est exclue if (deltaY != 0 && deltaX != 0) { // Si une place libre est trouv�e elle est ajout�e à la liste des coups try { - if ((this.board[y+deltaY][x+deltaX]==0)) { + if (this.board[y+deltaY][x+deltaX]==0) { moves.add(new Pair(new Point(y, x), new Point(y+deltaY, x+deltaX))); } + if(deltaX == 0 ^ deltaY == 0){ + if(this.board[y+2*deltaY][x+2*deltaX] == 0) + moves.add(new Pair(new Point(y, x), new Point(y+2*deltaY, x+2*deltaX))); + + } } catch(ArrayIndexOutOfBoundsException ignored) {} } }