diff --git a/src/search.cpp b/src/search.cpp index babe6f05c..5988c23fd 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -853,6 +853,12 @@ Value Search::Worker::search( else return ttData.value; } + } // No cutoff, but why? Does the stored inexact value mismatch our aspiration window? + else if (!PvNode && !excludedMove && ttData.depth > depth - (ttData.value <= beta) + && is_valid(ttData.value) && ttData.bound != BOUND_EXACT + && ttData.bound & (ttData.value >= beta ? BOUND_UPPER : BOUND_LOWER) && depth > 5) + { // If a window-bound mismatch is the only reason cutoff failed, penalize the now-useless tte + ttWriter.penalize(1); } // Step 6. Tablebases probe diff --git a/src/tt.cpp b/src/tt.cpp index 359399347..7f7c5ab4e 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -75,6 +75,7 @@ struct TTEntry { private: friend class TranspositionTable; + friend struct TTWriter; uint16_t key16; uint8_t depth8; @@ -137,6 +138,11 @@ void TTWriter::write( entry->save(k, v, pv, b, d, m, ev, curr_generation); } +void TTWriter::penalize(int penalty) { + assert(entry->depth8 + DEPTH_NONE > penalty); + entry->depth8 -= penalty; +} + // A TranspositionTable is an array of Cluster, of size clusterCount. Each cluster consists of ClusterSize number // of TTEntry. Each non-empty TTEntry contains information on exactly one position. The size of a Cluster should diff --git a/src/tt.h b/src/tt.h index 584b92bff..2f8091725 100644 --- a/src/tt.h +++ b/src/tt.h @@ -68,6 +68,7 @@ struct TTData { struct TTWriter { public: void write(Key k, Value v, bool pv, Bound b, Depth d, Move m, Value ev, uint8_t generation8); + void penalize(int penalty); // decrement stored depth by the penalty private: friend class TranspositionTable; diff --git a/tests/testing.py b/tests/testing.py index 619c8a59c..9711a43ba 100644 --- a/tests/testing.py +++ b/tests/testing.py @@ -51,6 +51,7 @@ class TSAN: """ race:Stockfish::TTEntry::read race:Stockfish::TTEntry::save +race:Stockfish::TTWriter::penalize race:Stockfish::TranspositionTable::probe race:Stockfish::TranspositionTable::hashfull """