diff --git a/src/othello/Main.java b/src/othello/Main.java index 7257b85..b125684 100644 --- a/src/othello/Main.java +++ b/src/othello/Main.java @@ -12,11 +12,8 @@ public class Main { while(!game.isOver()) { int player = game.getCurrentPlayer(); ArrayList> moves = game.getMove(player); + } - ArrayList a = new ArrayList<>(); - a.add(new Point(3,3)); - System.out.println(game.getMove(p1).toString()); - //System.out.println(a.get(0).toString()); } public static int[][] initialize(int p1, int p2){ diff --git a/src/othello/players/AbstractPlayer.java b/src/othello/players/AbstractPlayer.java new file mode 100644 index 0000000..6dd5a53 --- /dev/null +++ b/src/othello/players/AbstractPlayer.java @@ -0,0 +1,12 @@ +package othello.players; + +import java.util.ArrayList; + +import othello.Pair; +import othello.Point; + +public abstract class AbstractPlayer { + + public abstract Pair play(ArrayList> moves); + +} diff --git a/src/othello/players/RandomPlayer.java b/src/othello/players/RandomPlayer.java index 1196add..3510b6c 100644 --- a/src/othello/players/RandomPlayer.java +++ b/src/othello/players/RandomPlayer.java @@ -1,5 +1,16 @@ package othello.players; -public class RandomPlayer { +import java.util.ArrayList; +import java.util.Random; + +import othello.Pair; +import othello.Point; + +public class RandomPlayer extends AbstractPlayer { + + @Override + public Pair play(ArrayList> moves) { + return moves.get(new Random().nextInt(moves.size())); + } }