mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-24 19:16:49 +08:00
Reorder conditions in LMR and pruning
Make code logic somewhat easier to follow. closes https://github.com/official-stockfish/Stockfish/pull/3285 No functional change.
This commit is contained in:
committed by
Joost VandeVondele
parent
23c385ec36
commit
2c1be0be8e
@@ -1039,8 +1039,20 @@ moves_loop: // When in check, search starts from here
|
||||
// Reduced depth of the next LMR search
|
||||
int lmrDepth = std::max(newDepth - reduction(improving, depth, moveCount), 0);
|
||||
|
||||
if ( !captureOrPromotion
|
||||
&& !givesCheck)
|
||||
if ( captureOrPromotion
|
||||
|| givesCheck)
|
||||
{
|
||||
// Capture history based pruning when the move doesn't give check
|
||||
if ( !givesCheck
|
||||
&& lmrDepth < 1
|
||||
&& captureHistory[movedPiece][to_sq(move)][type_of(pos.piece_on(to_sq(move)))] < 0)
|
||||
continue;
|
||||
|
||||
// SEE based pruning
|
||||
if (!pos.see_ge(move, Value(-218) * depth)) // (~25 Elo)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Countermoves based pruning (~20 Elo)
|
||||
if ( lmrDepth < 4 + ((ss-1)->statScore > 0 || (ss-1)->moveCount == 1)
|
||||
@@ -1062,18 +1074,6 @@ moves_loop: // When in check, search starts from here
|
||||
if (!pos.see_ge(move, Value(-(30 - std::min(lmrDepth, 18)) * lmrDepth * lmrDepth)))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Capture history based pruning when the move doesn't give check
|
||||
if ( !givesCheck
|
||||
&& lmrDepth < 1
|
||||
&& captureHistory[movedPiece][to_sq(move)][type_of(pos.piece_on(to_sq(move)))] < 0)
|
||||
continue;
|
||||
|
||||
// SEE based pruning
|
||||
if (!pos.see_ge(move, Value(-218) * depth)) // (~25 Elo)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Step 13. Extensions (~75 Elo)
|
||||
@@ -1192,7 +1192,14 @@ moves_loop: // When in check, search starts from here
|
||||
if (singularQuietLMR)
|
||||
r--;
|
||||
|
||||
if (!captureOrPromotion)
|
||||
if (captureOrPromotion)
|
||||
{
|
||||
// Unless giving check, this capture is likely bad
|
||||
if ( !givesCheck
|
||||
&& ss->staticEval + PieceValue[EG][pos.captured_piece()] + 210 * depth <= alpha)
|
||||
r++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Increase reduction if ttMove is a capture (~5 Elo)
|
||||
if (ttCapture)
|
||||
@@ -1228,13 +1235,6 @@ moves_loop: // When in check, search starts from here
|
||||
// Decrease/increase reduction for moves with a good/bad history (~30 Elo)
|
||||
r -= ss->statScore / 14884;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unless giving check, this capture is likely bad
|
||||
if ( !givesCheck
|
||||
&& ss->staticEval + PieceValue[EG][pos.captured_piece()] + 210 * depth <= alpha)
|
||||
r++;
|
||||
}
|
||||
|
||||
Depth d = std::clamp(newDepth - r, 1, newDepth);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user