Skip to content

Commit

Permalink
Remove rootDelta branch
Browse files Browse the repository at this point in the history
This makes rootDelta logic easier to understand, recalculating the value
where it belongs so removes an unnecessary branch.

No functional change
  • Loading branch information
peregrineshahin authored and PikaCat-OuO committed May 27, 2024
1 parent 6775f46 commit f234d18
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
src/.depend

# Files from Qt
build
CMakeLists.txt
CMakeLists.txt.user

Expand Down
6 changes: 2 additions & 4 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ void Search::Worker::iterative_deepening() {
// for every four searchAgain steps (see issue #2717).
Depth adjustedDepth =
std::max(1, rootDepth - failedHighCnt - 3 * (searchAgainCounter + 1) / 4);
rootDelta = beta - alpha;
bestValue = search<Root>(rootPos, ss, alpha, beta, adjustedDepth, false);

// Bring the best move to the front. It is critical that sorting
Expand Down Expand Up @@ -538,8 +539,6 @@ Value Search::Worker::search(
if (alpha >= beta)
return alpha;
}
else
thisThread->rootDelta = beta - alpha;

assert(0 <= ss->ply && ss->ply < MAX_PLY);

Expand Down Expand Up @@ -670,8 +669,7 @@ Value Search::Worker::search(
&& eval - futility_margin(depth, cutNode && !ss->ttHit, improving, opponentWorsening)
- (ss - 1)->statScore / 210
>= beta
&& eval >= beta && eval < 18675 // smaller than wins.
&& (!ttMove || ttCapture))
&& eval >= beta && eval < VALUE_MATE_IN_MAX_PLY && (!ttMove || ttCapture))
return beta > VALUE_MATED_IN_MAX_PLY ? (eval + beta) / 2 : eval;

// Step 8. Null move search with verification search (~35 Elo)
Expand Down

0 comments on commit f234d18

Please sign in to comment.