19 lines
435 B
Java
19 lines
435 B
Java
|
|
import java.util.Random;
|
||
|
|
|
||
|
|
public class AIPlayer extends Player {
|
||
|
|
private Random random;
|
||
|
|
|
||
|
|
public AIPlayer(char mark) {
|
||
|
|
super(mark);
|
||
|
|
random = new Random();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void makeMove(Board board) {
|
||
|
|
int row, col;
|
||
|
|
do {
|
||
|
|
row = random.nextInt(3);
|
||
|
|
col = random.nextInt(3);
|
||
|
|
} while (!board.isCellEmpty(row, col));
|
||
|
|
board.placeMark(row, col, getMark());
|
||
|
|
}
|
||
|
|
}
|