Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce probCut for check evasions #3362

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,25 @@ namespace {

moves_loop: // When in check, search starts from here

ttCapture = ttMove && pos.capture_or_promotion(ttMove);
probCutBeta = beta + 400;

// Step 11. Probcut if we are in check.
// If transposition table move is a capture and value produced by it if much above beta
// produce a cutoff in the same way as we do in probCut.
// This can only happen if we are in check since if we were not in check we would've already
// produced a probCut cutoff.
if ( ss->inCheck
&& !PvNode
&& depth >= 4
&& ttCapture
&& (tte->bound() & BOUND_LOWER)
&& tte->depth() >= depth - 3
&& ttValue >= probCutBeta
&& abs(ttValue) <= VALUE_KNOWN_WIN
&& abs(beta) <= VALUE_KNOWN_WIN)
return probCutBeta;

const PieceToHistory* contHist[] = { (ss-1)->continuationHistory, (ss-2)->continuationHistory,
nullptr , (ss-4)->continuationHistory,
nullptr , (ss-6)->continuationHistory };
Expand All @@ -985,12 +1004,11 @@ namespace {

value = bestValue;
singularQuietLMR = moveCountPruning = false;
ttCapture = ttMove && pos.capture_or_promotion(ttMove);

// Mark this node as being searched
ThreadHolding th(thisThread, posKey, ss->ply);

// Step 11. Loop through all pseudo-legal moves until no moves remain
// Step 12. Loop through all pseudo-legal moves until no moves remain
// or a beta cutoff occurs.
while ((move = mp.next_move(moveCountPruning)) != MOVE_NONE)
{
Expand Down Expand Up @@ -1036,7 +1054,7 @@ namespace {
// Calculate new depth for this move
newDepth = depth - 1;

// Step 12. Pruning at shallow depth (~200 Elo)
// Step 13. Pruning at shallow depth (~200 Elo)
if ( !rootNode
&& pos.non_pawn_material(us)
&& bestValue > VALUE_TB_LOSS_IN_MAX_PLY)
Expand Down Expand Up @@ -1084,7 +1102,7 @@ namespace {
}
}

// Step 13. Extensions (~75 Elo)
// Step 14. Extensions (~75 Elo)

// Singular extension search (~70 Elo). If all moves but one fail low on a
// search of (alpha-s, beta-s), and just one fails high on (alpha, beta),
Expand Down Expand Up @@ -1156,10 +1174,10 @@ namespace {
[movedPiece]
[to_sq(move)];

// Step 14. Make the move
// Step 15. Make the move
pos.do_move(move, st, givesCheck);

// Step 15. Reduced depth search (LMR, ~200 Elo). If the move fails high it will be
// Step 16. Reduced depth search (LMR, ~200 Elo). If the move fails high it will be
// re-searched at full depth.
if ( depth >= 3
&& moveCount > 1 + 2 * rootNode
Expand Down Expand Up @@ -1266,7 +1284,7 @@ namespace {
didLMR = false;
}

// Step 16. Full depth search when LMR is skipped or fails high
// Step 17. Full depth search when LMR is skipped or fails high
if (doFullDepthSearch)
{
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, !cutNode);
Expand All @@ -1293,12 +1311,12 @@ namespace {
std::min(maxNextDepth, newDepth), false);
}

// Step 17. Undo move
// Step 18. Undo move
pos.undo_move(move);

assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);

// Step 18. Check for a new best move
// Step 19. Check for a new best move
// Finished searching the move. If a stop occurred, the return value of
// the search cannot be trusted, and we return immediately without
// updating best move, PV and TT.
Expand Down Expand Up @@ -1375,7 +1393,7 @@ namespace {
return VALUE_DRAW;
*/

// Step 19. Check for mate and stalemate
// Step 20. Check for mate and stalemate
// All legal moves have been searched and if there are no legal moves, it
// must be a mate or a stalemate. If we are in a singular extension search then
// return a fail low score.
Expand Down