Skip to content

Commit

Permalink
replace depth reduction condition with !opponentWorsening
Browse files Browse the repository at this point in the history
bench 1517399
  • Loading branch information
Ergodice committed Jan 18, 2025
1 parent c085670 commit 4e2f52d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,14 @@ void Search::Worker::iterative_deepening() {
&this->continuationHistory[0][0][NO_PIECE][0]; // Use as a sentinel
(ss - i)->continuationCorrectionHistory = &this->continuationCorrectionHistory[NO_PIECE][0];
(ss - i)->staticEval = VALUE_NONE;
(ss - i)->reduction = 0;
}

for (int i = 0; i <= MAX_PLY + 2; ++i)
{
(ss + i)->ply = i;
(ss + i)->reduction = 0;
}

ss->pv = pv;

Expand Down Expand Up @@ -567,6 +571,8 @@ Value Search::Worker::search(
Value bestValue, value, eval, maxValue, probCutBeta;
bool givesCheck, improving, priorCapture, opponentWorsening;
bool capture, ttCapture;
int priorReduction = ss->reduction;
ss->reduction = 0;
Piece movedPiece;

ValueList<Move, 32> capturesSearched;
Expand Down Expand Up @@ -772,6 +778,9 @@ Value Search::Worker::search(

opponentWorsening = ss->staticEval + (ss - 1)->staticEval > 2;

if (priorReduction >= 3 && !opponentWorsening) depth++;


// Step 7. Razoring (~1 Elo)
// If eval is really low, check with qsearch if we can exceed alpha. If the
// search suggests we cannot exceed alpha, return a speculative fail low.
Expand Down Expand Up @@ -1192,10 +1201,16 @@ Value Search::Worker::search(
// beyond the first move depth.
// To prevent problems when the max value is less than the min value,
// std::clamp has been replaced by a more robust implementation.


Depth d = std::max(
1, std::min(newDepth - r / 1024, newDepth + !allNode + (PvNode && !bestMove)));

(ss + 1)->reduction = newDepth - d;

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


// Do a full-depth search when reduced LMR search fails high
if (value > alpha && d < newDepth)
Expand Down
1 change: 1 addition & 0 deletions src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct Stack {
bool ttPv;
bool ttHit;
int cutoffCnt;
int reduction;
};


Expand Down

0 comments on commit 4e2f52d

Please sign in to comment.