diff --git a/src/ChessAI.java b/src/ChessAI.java index bf20af5..9d3c1cd 100644 --- a/src/ChessAI.java +++ b/src/ChessAI.java @@ -1,3 +1,6 @@ +import java.util.ArrayList; +import java.util.Collections; + public class ChessAI { private static final int MAX_DEPTH = 3; @@ -5,7 +8,9 @@ public class ChessAI { int bestScore = Integer.MIN_VALUE; Move bestMove = null; - for (Move move : board.getAllLegalMoves(true)) { + ArrayList legalMoves = board.getAllLegalMoves(true); + Collections.shuffle(legalMoves); + for (Move move : legalMoves) { board.move(move); int score = minimax(board, MAX_DEPTH, Integer.MIN_VALUE, Integer.MAX_VALUE, false); board.undoMove();