Files
Fondamentaux-TP1/TTT_java/AIPlayer.java

19 lines
435 B
Java
Raw Normal View History

2025-10-14 17:21:26 +02:00
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());
}
}