Skip to content

Commit

Permalink
Avoid wrongful TT/history updates when unwinding the search during a …
Browse files Browse the repository at this point in the history
…thread stop

Probcut does not have the same logic that exists in the primary move loop during pvsearch, which guards against acting on invalid scores from child nodes. With this, it does. The solution, and the comment, are copy-pasted from the other location.
  • Loading branch information
PikaCat-OuO committed Nov 14, 2024
1 parent 85a83ba commit 7a2a1cf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,11 @@ Value Search::Worker::search(

if (value >= probCutBeta)
{
// If a stop occurred, the return value of the search cannot be trusted, and we
// must return immediately without updating any histories nor the transposition table.
if (threads.stop.load(std::memory_order_relaxed))
return VALUE_ZERO;

thisThread->captureHistory[movedPiece][move.to_sq()][type_of(captured)]
<< stat_bonus(depth - 2);

Expand Down

0 comments on commit 7a2a1cf

Please sign in to comment.