28 lines
543 B
Java
28 lines
543 B
Java
package chess.ai;
|
|
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
|
|
import chess.ai.actions.AIAction;
|
|
import chess.controller.CommandExecutor;
|
|
import chess.model.Color;
|
|
|
|
public class DumbAI extends AI {
|
|
|
|
private final Random random = new Random();
|
|
|
|
public DumbAI(CommandExecutor commandExecutor, Color color) {
|
|
super(commandExecutor, color);
|
|
}
|
|
|
|
@Override
|
|
protected void play() {
|
|
List<AIAction> actions = getAllowedActions();
|
|
|
|
int randomAction = this.random.nextInt(actions.size());
|
|
|
|
actions.get(randomAction).applyAction();
|
|
}
|
|
|
|
}
|