From c7688feaa387e9cd0fd4dc3c41378efbafb4260b Mon Sep 17 00:00:00 2001 From: Antonin Boyon Date: Wed, 27 Jan 2021 16:55:50 +0100 Subject: [PATCH] =?UTF-8?q?fonction=20de=20clonage=20des=20pions=20pour=20?= =?UTF-8?q?la=20m=C3=A9thode=20getMove?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/othello/Main.java | 10 +++++----- src/othello/State.java | 31 +++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/othello/Main.java b/src/othello/Main.java index 860769b..c1b0194 100644 --- a/src/othello/Main.java +++ b/src/othello/Main.java @@ -4,17 +4,17 @@ public class Main { public static void main(String[] args) { - String p1 = "B", p2 = "R"; - String[][] board = initialize(p1, p2); + int p1 = 1, p2 = 2; + int[][] board = initialize(p1, p2); State game = new State(board, p1, p2); while(!game.isOver()) { - String player = game.getCurrentPlayer(); + int player = game.getCurrentPlayer(); } } - public static String[][] initialize(String p1, String p2){ - String[][] board = new String[7][7]; + public static int[][] initialize(int p1, int p2){ + int[][] board = new int[7][7]; board[0][0] = p2; board[0][6] = p1; board[6][0] = p1; diff --git a/src/othello/State.java b/src/othello/State.java index 7dcca67..a545822 100644 --- a/src/othello/State.java +++ b/src/othello/State.java @@ -1,5 +1,6 @@ package othello; +import java.awt.Point; import java.util.ArrayList; public class State { @@ -20,8 +21,34 @@ public class State { return false; } - public ArrayList getMove(String player) { - return null; + public ArrayList getMove(String player) { + ArrayList moves = null; + + // Clonage + // Parcours du plateau de jeu + for (int i=0; i