added abstractPlayer and RandomPlayer
This commit is contained in:
parent
d4437f8b87
commit
af4d9d8504
@ -12,11 +12,8 @@ public class Main {
|
|||||||
while(!game.isOver()) {
|
while(!game.isOver()) {
|
||||||
int player = game.getCurrentPlayer();
|
int player = game.getCurrentPlayer();
|
||||||
ArrayList<Pair<Point, Point>> moves = game.getMove(player);
|
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){
|
public static int[][] initialize(int p1, int p2){
|
||||||
|
12
src/othello/players/AbstractPlayer.java
Normal file
12
src/othello/players/AbstractPlayer.java
Normal 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);
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,16 @@
|
|||||||
package othello.players;
|
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()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user