Files
3DChess/app/src/main/java/chess/ai/AI.java
Persson-dev 810a0f2159
All checks were successful
Linux arm64 / Build (push) Successful in 41s
feat: add ai castling (Fixes #4)
2025-05-06 17:15:55 +02:00

42 lines
931 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;
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<AIAction> getAllowedActions() {
return AIActions.getAllowedActions(this.commandExecutor);
}
protected Piece pieceAt(Coordinate coordinate) {
return AIActions.pieceAt(coordinate, this.commandExecutor);
}
}