42 lines
864 B
Java
42 lines
864 B
Java
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;
|
|
|
|
/**
|
|
* Abstract class, used to code bots.
|
|
*/
|
|
public abstract class AI extends GameAdapter implements AIActions {
|
|
|
|
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();
|
|
}
|
|
|
|
@Override
|
|
public CommandExecutor getCommandExecutor() {
|
|
return this.commandExecutor;
|
|
}
|
|
|
|
}
|