package chess.ai; import java.util.List; import chess.ai.actions.AIAction; import chess.ai.actions.AIActions; import chess.controller.CommandExecutor; import chess.controller.event.GameAdapter; import chess.model.Color; import chess.model.Coordinate; import chess.model.Piece; public abstract class AI extends GameAdapter { protected final CommandExecutor commandExecutor; protected final Color color; public AI(CommandExecutor commandExecutor, Color color) { this.commandExecutor = commandExecutor; this.color = color; } protected abstract void play(); @Override public void onPlayerTurn(Color color, boolean undone) { if (this.color != color || undone) return; play(); } protected List getAllowedActions() { return AIActions.getAllowedActions(this.commandExecutor); } protected Piece pieceAt(Coordinate coordinate) { return AIActions.pieceAt(coordinate, this.commandExecutor); } }