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

Range reductions #3717

Closed
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ Unai Corzo (unaiic)
Uri Blass (uriblass)
Vince Negri (cuddlestmonkey)
zz4032
Ofek Shochat (ghostway)


# Additionally, we acknowledge the authors and maintainers of fishtest,
Expand Down
14 changes: 10 additions & 4 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ namespace {
// Reductions lookup table, initialized at startup
int Reductions[MAX_MOVES]; // [depth or moveNumber]

Depth reduction(bool i, Depth d, int mn) {
Depth reduction(bool i, Depth d, int mn, bool rangeReduction) {
int r = Reductions[d] * Reductions[mn];
return (r + 534) / 1024 + (!i && r > 904);
return (r + 534) / 1024 + (!i && r > 904) + rangeReduction;
}

constexpr int futility_move_count(bool improving, Depth depth) {
Expand Down Expand Up @@ -955,6 +955,7 @@ namespace {

ttCapture = ttMove && pos.capture_or_promotion(ttMove);

int rangeReduction = 0;
// Step 11. A small Probcut idea, when we are in check
probCutBeta = beta + 409;
if ( ss->inCheck
Expand Down Expand Up @@ -1041,7 +1042,7 @@ namespace {
moveCountPruning = moveCount >= futility_move_count(improving, depth);

// Reduced depth of the next LMR search
int lmrDepth = std::max(newDepth - reduction(improving, depth, moveCount), 0);
int lmrDepth = std::max(newDepth - reduction(improving, depth, moveCount, rangeReduction > 2), 0);

if ( captureOrPromotion
|| givesCheck)
Expand Down Expand Up @@ -1176,7 +1177,7 @@ namespace {
|| !ss->ttPv)
&& (!PvNode || ss->ply > 1 || thisThread->id() % 4 != 3))
{
Depth r = reduction(improving, depth, moveCount);
Depth r = reduction(improving, depth, moveCount, rangeReduction > 2);

if (PvNode)
r--;
Expand Down Expand Up @@ -1236,6 +1237,11 @@ namespace {

value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, d, true);

// Range reductions (~3 Elo)
if (ss->staticEval - value < 30 && depth > 7) {
rangeReduction += 1;
}

// If the son is reduced and fails high it will be re-searched at full depth
doFullDepthSearch = value > alpha && d < newDepth;
didLMR = true;
Expand Down