added abstractPlayer and RandomPlayer

This commit is contained in:
Quentin Legot 2021-02-10 12:19:22 +01:00
parent d4437f8b87
commit af4d9d8504
3 changed files with 25 additions and 5 deletions

View File

@ -12,11 +12,8 @@ public class Main {
while(!game.isOver()) {
int player = game.getCurrentPlayer();
ArrayList<Pair<Point, Point>> moves = game.getMove(player);
}
ArrayList<Point> 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){

View File

@ -0,0 +1,12 @@
package othello.players;
import java.util.ArrayList;
import othello.Pair;
import othello.Point;
public abstract class AbstractPlayer {
public abstract Pair<Point, Point> play(ArrayList<Pair<Point, Point>> moves);
}

View File

@ -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<Point, Point> play(ArrayList<Pair<Point, Point>> moves) {
return moves.get(new Random().nextInt(moves.size()));
}
}