Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Engine
- {
- public static int search(int depth, int alpha, int beta, Board board, int ply)
- {
- if (board.isMated())
- {
- return -100000 + ply;
- }
- if (board.isDraw())
- {
- return 0;
- }
- if (depth <= 0)
- {
- return qsearch(alpha, beta, board, ply);
- }
- int bestValue = Integer.MIN_VALUE;
- for (Move move : board.legalMoves())
- {
- board.doMove(move);
- nodes++;
- int thisMoveValue = -search(depth - 1, -beta, -alpha, board, ply + 1);
- board.undoMove();
- bestValue = Math.max(thisMoveValue, bestValue);
- if (bestValue > alpha)
- {
- if (bestValue > beta)
- {
- return bestValue;
- }
- alpha = bestValue;
- }
- }
- return bestValue;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement