Simplify saving a TT entry.

Avoid passing TT.generation() to TTEntry::save() at every call,
moving the implementation of TTEntry::save from tt.h to tt.cpp.

tested for no regression:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 53787 W: 11948 L: 11890 D: 29949
http://tests.stockfishchess.org/tests/view/5b2ff37f0ebc5902b2e582fe

Closes https://github.com/official-stockfish/Stockfish/pull/1662

No functional change.
This commit is contained in:
Joost VandeVondele
2018-07-04 00:58:16 +02:00
committed by Stéphane Nicolet
parent 8c4f0ffa1d
commit e7cfa5d020
3 changed files with 31 additions and 29 deletions

View File

@@ -29,6 +29,28 @@
TranspositionTable TT; // Our global transposition table
/// TTEntry::save saves a TTEntry
void TTEntry::save(Key k, Value v, Bound b, Depth d, Move m, Value ev) {
assert(d / ONE_PLY * ONE_PLY == d);
// Preserve any existing move for the same position
if (m || (k >> 48) != key16)
move16 = (uint16_t)m;
// Overwrite less valuable entries
if ( (k >> 48) != key16
|| d / ONE_PLY > depth8 - 4
|| b == BOUND_EXACT)
{
key16 = (uint16_t)(k >> 48);
value16 = (int16_t)v;
eval16 = (int16_t)ev;
genBound8 = (uint8_t)(TT.generation8 | b);
depth8 = (int8_t)(d / ONE_PLY);
}
}
/// TranspositionTable::resize() sets the size of the transposition table,
/// measured in megabytes. Transposition table consists of a power of 2 number