Autoplayer implemented (needs to modify speed and checkmate condition)

This commit is contained in:
manon 2025-05-20 11:08:08 +02:00
parent 21ff8c1b01
commit 58f038d0f2
2 changed files with 9 additions and 5 deletions

View File

@ -381,8 +381,11 @@ public class Board {
} }
public void playMove(Move move) { public void playMove(Move move) {
if (move == null) return; if (move == null || move.getPiece() == null) {
System.out.println("Invalid move: " + move);
return;
}
Piece piece = move.getPiece(); Piece piece = move.getPiece();
int toX = move.getToX(); int toX = move.getToX();
int toY = move.getToY(); int toY = move.getToY();

View File

@ -52,9 +52,10 @@ public class Game extends Thread {
} }
private void aiPlayerTurn() { private void aiPlayerTurn() {
if(isAITurn()) { if (isAITurn()) {
board.playMove(aiPlayer.computeBestMove(new Board(board))); Move move = aiPlayer.computeBestMove(board); // Use the actual board
} board.playMove(move); // Move from the actual board
}
} }
public void clickCoords(int x, int y) { public void clickCoords(int x, int y) {