Autoplayer implemented (needs to modify speed and checkmate condition)
This commit is contained in:
parent
21ff8c1b01
commit
58f038d0f2
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue