From 93d83adad73cd11809d9bf756329c70ffef4cb4b Mon Sep 17 00:00:00 2001 From: Antonin Boyon <22009544@etu.unicaen.fr> Date: Wed, 10 Feb 2021 13:35:22 +0100 Subject: [PATCH] =?UTF-8?q?m=C3=A9thode=20getMoves?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/othello/Main.java | 8 +++++--- src/othello/Point.java | 5 +++++ src/othello/State.java | 1 - 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/othello/Main.java b/src/othello/Main.java index b125684..1dfbe0a 100644 --- a/src/othello/Main.java +++ b/src/othello/Main.java @@ -9,11 +9,13 @@ public class Main { int p1 = 1, p2 = 2; int[][] board = initialize(p1, p2); State game = new State(board, p1, p2); - while(!game.isOver()) { + board[1][5]=game.getCurrentPlayer(); + /*while(!game.isOver()) { int player = game.getCurrentPlayer(); ArrayList> moves = game.getMove(player); - - } + } */ + ArrayList> moves = game.getMove(game.getCurrentPlayer()); + System.out.println(moves.toString()); } public static int[][] initialize(int p1, int p2){ diff --git a/src/othello/Point.java b/src/othello/Point.java index 4e0b11a..26e4a53 100644 --- a/src/othello/Point.java +++ b/src/othello/Point.java @@ -14,4 +14,9 @@ public class Point { return Math.pow(other.x - this.x, 2) + Math.pow(other.y - this.y, 2) == 4; } + @Override + public String toString () { + return "("+x+","+y+")"; + } + } diff --git a/src/othello/State.java b/src/othello/State.java index 97aa46b..d8266e8 100644 --- a/src/othello/State.java +++ b/src/othello/State.java @@ -50,7 +50,6 @@ public class State { if(this.board[y+deltaY][x+deltaX]!=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) {} }