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

Replace distanceFromPv with a better logic. #3421

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
11 changes: 4 additions & 7 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ namespace {
moveCount = captureCount = quietCount = ss->moveCount = 0;
bestValue = -VALUE_INFINITE;
maxValue = VALUE_INFINITE;
ss->distanceFromPv = (PvNode ? 0 : ss->distanceFromPv);

// Check for the available remaining time
if (thisThread == Threads.main())
Expand Down Expand Up @@ -1180,8 +1179,6 @@ namespace {
// Step 15. Make the move
pos.do_move(move, st, givesCheck);

(ss+1)->distanceFromPv = ss->distanceFromPv + moveCount - 1;

// Step 16. Late moves reduction / extension (LMR, ~200 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
Expand Down Expand Up @@ -1280,10 +1277,10 @@ namespace {
r -= ss->statScore / 14790;
}

// In general we want to cap the LMR depth search at newDepth. But for nodes
// close to the principal variation the cap is at (newDepth + 1), which will
// allow these nodes to be searched deeper than the pv (up to 4 plies deeper).
Depth d = std::clamp(newDepth - r, 1, newDepth + ((ss+1)->distanceFromPv <= 4));
// In general we want to cap the LMR depth search at newDepth.
// But if reductions are really negative and movecount is low we allow this
// moves to be searched deeper than the first move.
Depth d = std::clamp(newDepth - r, 1, newDepth + (r < -1 && moveCount <= 5));

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

Expand Down
1 change: 0 additions & 1 deletion src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ struct Stack {
Value staticEval;
int statScore;
int moveCount;
int distanceFromPv;
bool inCheck;
bool ttPv;
bool ttHit;
Expand Down