mcostalba wrote:Ralph Stoesser wrote:
The move store/replacement code is slightly expensive and tricky, but first experiments with two TT moves look promising. Unfortunately a move needs 17 bit instead of 16 bit. A 16 bit requirement would fit much better w.r.t the storage of several TT moves. The promotion piece type in the move encoding demands 3 bits, but 2 bits should be enough.
How do you handle 2 TT moves for the same position with different depths ?
I have an idea on how to implement 2 TT moves per position in a clean way (although I don't know how efficient), anyhow I am interested to see your results before start coding...
currently I think a scheme similar to history counters could be the goal. If a move is cut-off move at depth d add d*d to the move ordering score, but then we would need additional score counters, therefore this is probably too expensive...
Anyway, my first try looks like this
Code: Select all
void TranspositionTable::store(const Key posKey, Value v, ValueType t, Depth d, Move m, Value statV, Value kingD) {
int c1, c2, c3;
TTEntry *tte, *replace;
uint32_t posKey32 = posKey >> 32; // Use the high 32 bits as key
Move m2 = MOVE_NONE;
tte = replace = first_entry(posKey);
for (int i = 0; i < ClusterSize; i++, tte++)
{
if (!tte->key() || tte->key() == posKey32) // empty or overwrite old
{
if (m == MOVE_NONE)
{
// preserve any existing ttMoves
m = tte->move();
m2 = tte->move2();
}
else if (m != tte->move())
{
// overwrite first ttMove?
if (d >= tte->depth())
{
// yes, also store the previous first ttMove in slot #2
m2 = tte->move();
}
else
{
// no, but store the new move in slot #2 in case it is empty
if (tte->move2())
m2 = tte->move2();
else
m2 = m;
m = tte->move();
}
}
tte->save(posKey32, v, t, d, m, m2, generation, statV, kingD);
return;
}
if (i == 0) // Replacing first entry is default and already set before entering for-loop
continue;
c1 = (replace->generation() == generation ? 2 : 0);
c2 = (tte->generation() == generation ? -2 : 0);
c3 = (tte->depth() < replace->depth() ? 1 : 0);
if (c1 + c2 + c3 > 0)
replace = tte;
}
replace->save(posKey32, v, t, d, m, m2, generation, statV, kingD);
}
Testing: 256 MB Hash, 1 Thread, tc 1+0
Score of test vs default: +131 -100 =280
so far ...