|
|
@ -5,7 +5,7 @@ public class ChessAI {
|
|
|
|
int bestScore = Integer.MIN_VALUE;
|
|
|
|
int bestScore = Integer.MIN_VALUE;
|
|
|
|
Move bestMove = null;
|
|
|
|
Move bestMove = null;
|
|
|
|
|
|
|
|
|
|
|
|
for (Move move : board.getAllLegalMoves()) {
|
|
|
|
for (Move move : board.getAllLegalMoves(true)) {
|
|
|
|
board.move(move);
|
|
|
|
board.move(move);
|
|
|
|
int score = minimax(board, MAX_DEPTH, Integer.MIN_VALUE, Integer.MAX_VALUE, false);
|
|
|
|
int score = minimax(board, MAX_DEPTH, Integer.MIN_VALUE, Integer.MAX_VALUE, false);
|
|
|
|
board.undoMove();
|
|
|
|
board.undoMove();
|
|
|
@ -27,7 +27,7 @@ public class ChessAI {
|
|
|
|
int score;
|
|
|
|
int score;
|
|
|
|
if (maximizingPlayer) {
|
|
|
|
if (maximizingPlayer) {
|
|
|
|
score = Integer.MIN_VALUE;
|
|
|
|
score = Integer.MIN_VALUE;
|
|
|
|
for (Move move : board.getAllLegalMoves()) {
|
|
|
|
for (Move move : board.getAllLegalMoves(true)) {
|
|
|
|
board.move(move);
|
|
|
|
board.move(move);
|
|
|
|
score = Math.max(score, minimax(board, depth - 1, alpha, beta, false));
|
|
|
|
score = Math.max(score, minimax(board, depth - 1, alpha, beta, false));
|
|
|
|
board.undoMove();
|
|
|
|
board.undoMove();
|
|
|
@ -38,7 +38,7 @@ public class ChessAI {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
score = Integer.MAX_VALUE;
|
|
|
|
score = Integer.MAX_VALUE;
|
|
|
|
for (Move move : board.getAllLegalMoves()) {
|
|
|
|
for (Move move : board.getAllLegalMoves(true)) {
|
|
|
|
board.move(move);
|
|
|
|
board.move(move);
|
|
|
|
score = Math.min(score, minimax(board, depth - 1, alpha, beta, true));
|
|
|
|
score = Math.min(score, minimax(board, depth - 1, alpha, beta, true));
|
|
|
|
board.undoMove();
|
|
|
|
board.undoMove();
|
|
|
|