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

Sometimes do a reduced search in case LMR is skipped #4290

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
94 changes: 47 additions & 47 deletions src/search.cpp
Expand Up @@ -1120,62 +1120,62 @@ namespace {
// Step 16. Make the move
pos.do_move(move, st, givesCheck);

// Step 17. Late moves reduction / extension (LMR, ~98 Elo)
// We use various heuristics for the sons of a node after the first son has
// been searched. In general we would like to reduce them, but there are many
// cases where we extend a son if it has good chances to be "interesting".
if ( depth >= 2
&& moveCount > 1 + (PvNode && ss->ply <= 1)
&& ( !ss->ttPv
|| !capture
|| (cutNode && (ss-1)->moveCount > 1)))
{
Depth r = reduction(improving, depth, moveCount, delta, thisThread->rootDelta);
Depth r = reduction(improving, depth, moveCount, delta, thisThread->rootDelta);

// Decrease reduction if position is or has been on the PV
// and node is not likely to fail low. (~3 Elo)
if ( ss->ttPv
&& !likelyFailLow)
r -= 2;
// Decrease reduction if position is or has been on the PV
// and node is not likely to fail low. (~3 Elo)
if ( ss->ttPv
&& !likelyFailLow)
r -= 2;

// Decrease reduction if opponent's move count is high (~1 Elo)
if ((ss-1)->moveCount > 7)
r--;
// Decrease reduction if opponent's move count is high (~1 Elo)
if ((ss-1)->moveCount > 7)
r--;

// Increase reduction for cut nodes (~3 Elo)
if (cutNode)
r += 2;
// Increase reduction for cut nodes (~3 Elo)
if (cutNode)
r += 2;

// Increase reduction if ttMove is a capture (~3 Elo)
if (ttCapture)
r++;
// Increase reduction if ttMove is a capture (~3 Elo)
if (ttCapture)
r++;

// Decrease reduction for PvNodes based on depth
if (PvNode)
r -= 1 + 11 / (3 + depth);
// Decrease reduction for PvNodes based on depth
if (PvNode)
r -= 1 + 11 / (3 + depth);

// Decrease reduction if ttMove has been singularly extended (~1 Elo)
if (singularQuietLMR)
r--;
// Decrease reduction if ttMove has been singularly extended (~1 Elo)
if (singularQuietLMR)
r--;

// Decrease reduction if we move a threatened piece (~1 Elo)
if ( depth > 9
&& (mp.threatenedPieces & from_sq(move)))
r--;
// Decrease reduction if we move a threatened piece (~1 Elo)
if ( depth > 9
&& (mp.threatenedPieces & from_sq(move)))
r--;

// Increase reduction if next ply has a lot of fail high
if ((ss+1)->cutoffCnt > 3)
r++;
// Increase reduction if next ply has a lot of fail high
if ((ss+1)->cutoffCnt > 3)
r++;

ss->statScore = 2 * thisThread->mainHistory[us][from_to(move)]
+ (*contHist[0])[movedPiece][to_sq(move)]
+ (*contHist[1])[movedPiece][to_sq(move)]
+ (*contHist[3])[movedPiece][to_sq(move)]
- 4433;
ss->statScore = 2 * thisThread->mainHistory[us][from_to(move)]
+ (*contHist[0])[movedPiece][to_sq(move)]
+ (*contHist[1])[movedPiece][to_sq(move)]
+ (*contHist[3])[movedPiece][to_sq(move)]
- 4433;

// Decrease/increase reduction for moves with a good/bad history (~30 Elo)
r -= ss->statScore / (13000 + 4152 * (depth > 7 && depth < 19));
// Decrease/increase reduction for moves with a good/bad history (~30 Elo)
r -= ss->statScore / (13000 + 4152 * (depth > 7 && depth < 19));

// Step 17. Late moves reduction / extension (LMR, ~98 Elo)
// We use various heuristics for the sons of a node after the first son has
// been searched. In general we would like to reduce them, but there are many
// cases where we extend a son if it has good chances to be "interesting".
if ( depth >= 2
&& moveCount > 1 + (PvNode && ss->ply <= 1)
&& ( !ss->ttPv
|| !capture
|| (cutNode && (ss-1)->moveCount > 1)))
{
// In general we want to cap the LMR depth search at newDepth, but when
// reduction is negative, we allow this move a limited search extension
// beyond the first move depth. This may lead to hidden double extensions.
Expand Down Expand Up @@ -1209,10 +1209,10 @@ namespace {
}
}

// Step 18. Full depth search when LMR is skipped
// Step 18. Full depth search when LMR is skipped. If expected reduction is high, reduce it's depth by 1.
else if (!PvNode || moveCount > 1)
{
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, !cutNode);
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth - (r > 4), !cutNode);
}

// For PV nodes only, do a full PV search on the first move or after a fail
Expand Down