Skip to content

Commit

Permalink
skip shallow pruning if we need to check child db record
Browse files Browse the repository at this point in the history
[skip_fishtest]
  • Loading branch information
dhbloo committed Oct 14, 2024
1 parent 66a4008 commit 58ed3f3
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions Rapfi/search/ab/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,20 +721,23 @@ Value search(Board &board, SearchStack *ss, Value alpha, Value beta, Depth depth

// Step 5. Database query
Database::DBRecord dbRecord;
bool dbHit = false;
bool dbHit = false, dbCheckChild = false;
Bound dbLabelBound = BOUND_NONE, dbBound = BOUND_NONE;
Value dbValue;
if (thisThread->dbClient && !skipMove // Do not query database in singular extension
&& ss->ply <= Config::DatabaseQueryPly
+ searchData->rootDepth
if (thisThread->dbClient) {
Database::DBClient &dbClient = *thisThread->dbClient;
int queryPlyIncrement = searchData->rootDepth
/ (PvNode ? Config::DatabaseQueryPVIterPerPlyIncrement
: Config::DatabaseQueryNonPVIterPerPlyIncrement)) {
Database::DBClient &dbClient = *thisThread->dbClient;
: Config::DatabaseQueryNonPVIterPerPlyIncrement);
int queryPly = Config::DatabaseQueryPly + queryPlyIncrement;

if (dbClient.query(board, Rule, dbRecord)) {
dbHit = true;
dbValue = storedValueToSearchValue(dbRecord.value, ss->ply);
dbBound = dbRecord.bound();
if (!skipMove // Skip query in singular extension
&& ss->ply <= queryPly // Only query in the first plies to avoid large speed loss
&& dbClient.query(board, Rule, dbRecord)) {
dbHit = true;
dbValue = storedValueToSearchValue(dbRecord.value, ss->ply);
dbBound = dbRecord.bound();
dbCheckChild = ss->ply < queryPly;

switch (dbRecord.label) {
case Database::LABEL_NULL: break;
Expand Down Expand Up @@ -998,7 +1001,8 @@ Value search(Board &board, SearchStack *ss, Value alpha, Value beta, Depth depth

// Step 12. Pruning at shallow depth
// Do pruning only when we have non-losing moves, otherwise we may have a false mate.
if (!RootNode && bestValue > VALUE_MATED_IN_MAX_PLY) {
// Also skip pruning if there might be a child database record we want to read.
if (!RootNode && !dbCheckChild && bestValue > VALUE_MATED_IN_MAX_PLY) {
// Move count pruning: skip move if movecount is above threshold (~107 elo)
if (moveCount >= futilityMoveCount(depth, improvement > 0))
continue;
Expand Down

0 comments on commit 58ed3f3

Please sign in to comment.