X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Ftt.h;h=ff1cb910f63035d1d9582fe652d9c91171dc521d;hp=8cba4c87cb5202d4db205dd9d04925cd3685d05f;hb=9f626725aeb770a38be093a9a47a461053cf7008;hpb=c7a932bc744f899f53ce0013cbbbaa86915bb2e8 diff --git a/src/tt.h b/src/tt.h index 8cba4c87..ff1cb910 100644 --- a/src/tt.h +++ b/src/tt.h @@ -64,6 +64,7 @@ public: staticValue = int16_t(statV); staticValueMargin = int16_t(kd); } + void set_generation(int g) { data = move() | (type() << 21) | (g << 23); } uint32_t key() const { return key32; } Depth depth() const { return Depth(depth16); } @@ -102,6 +103,9 @@ struct TTCluster { class TranspositionTable { + TranspositionTable(const TranspositionTable&); + TranspositionTable& operator=(const TranspositionTable&); + public: TranspositionTable(); ~TranspositionTable(); @@ -111,11 +115,12 @@ public: TTEntry* retrieve(const Key posKey) const; void new_search(); TTEntry* first_entry(const Key posKey) const; + void refresh(const TTEntry* tte) const; private: size_t size; TTCluster* entries; - uint8_t generation; + int generation; }; extern TranspositionTable TT; @@ -130,4 +135,13 @@ inline TTEntry* TranspositionTable::first_entry(const Key posKey) const { return entries[uint32_t(posKey) & (size - 1)].data; } + +/// TranspositionTable::refresh updates the 'generation' value of the TTEntry +/// to avoid aging. Normally called after a TT hit, before to return. + +inline void TranspositionTable::refresh(const TTEntry* tte) const { + + const_cast(tte)->set_generation(generation); +} + #endif // !defined(TT_H_INCLUDED)