]> git.sesse.net Git - stockfish/commitdiff
Better document entry age calculation used in TT replace.
authormstembera <MissingEmail@email>
Thu, 20 Aug 2015 19:24:37 +0000 (20:24 +0100)
committerJoona Kiiski <joona.kiiski@gmail.com>
Thu, 20 Aug 2015 19:27:06 +0000 (20:27 +0100)
No functional change.

Resolves #401
Resolves #400

src/tt.cpp

index a9f8f037ab92925f80a62c7a26d5dfc2be7849d7..f9674601373319bdd32003429d000a8dc99ac448 100644 (file)
@@ -87,6 +87,10 @@ TTEntry* TranspositionTable::probe(const Key key, bool& found) const {
   // Find an entry to be replaced according to the replacement strategy
   TTEntry* replace = tte;
   for (int i = 1; i < ClusterSize; ++i)
   // Find an entry to be replaced according to the replacement strategy
   TTEntry* replace = tte;
   for (int i = 1; i < ClusterSize; ++i)
+      // Due to our packed storage format for generation and its cyclic
+      // nature we add 259 (256 is the modulus plus 3 to keep the lowest
+      // two bound bits from affecting the result) to calculate the entry
+      // age correctly even after generation8 overflows into the next cycle.
       if (  replace->depth8 - ((259 + generation8 - replace->genBound8) & 0xFC) * 2 * ONE_PLY
           >   tte[i].depth8 - ((259 + generation8 -   tte[i].genBound8) & 0xFC) * 2 * ONE_PLY)
           replace = &tte[i];
       if (  replace->depth8 - ((259 + generation8 - replace->genBound8) & 0xFC) * 2 * ONE_PLY
           >   tte[i].depth8 - ((259 + generation8 -   tte[i].genBound8) & 0xFC) * 2 * ONE_PLY)
           replace = &tte[i];