diff --git a/src/tt.cpp b/src/tt.cpp index 0ad076c76..400a154d7 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -119,7 +119,8 @@ void TTEntry::save( { auto v16 = value16; if (std::abs(v16) < VALUE_INFINITE && is_decisive(v16)) - depth8--; + depth8 = std::max(int(depth8) - 1, + 0); // guard against racy underflows, default to "unoccupied" } } @@ -141,7 +142,10 @@ void TTWriter::write( entry->save(k, v, pv, b, d, m, ev, curr_generation); } -void TTWriter::penalize(int penalty) { entry->depth8 -= penalty; } +void TTWriter::penalize(int penalty) { + // guard against racy underflows, default to "unoccupied" + entry->depth8 = std::max(int(entry->depth8) - penalty, 0); +} // A TranspositionTable is an array of Cluster, of size clusterCount. Each cluster consists of ClusterSize number