strange code for tt
Posted: Tue Jun 18, 2019 5:21 pm
Hi,
For ages (micah, embla, feeks, etc, all of them) I had this piece of code for updating the transposition table:
Today I looked at it and it doesn't make sense I think. if alpha > start_alpha (which is the alpha at the start of search()), then the best_score can never be <= start_alpha. So never an upperbound. I tried removing the alpha > start_alpha check but that makes it play -80 elo.
Any insights?
For completeness, here's also the look-up code:
For ages (micah, embla, feeks, etc, all of them) I had this piece of code for updating the transposition table:
Code: Select all
if (alpha > start_alpha && !to_flag) {
tt_entry_flag flag = EXACT;
if (best_score <= start_alpha)
flag = UPPERBOUND;
else if (best_score >= beta)
flag = LOWERBOUND;
meta->tti->store(pos.hash(), flag, depth, best_score, best_score <= start_alpha ? MOVE_NONE : best_move);
}
Any insights?
For completeness, here's also the look-up code:
Code: Select all
tt_entry te;
libchess::Move tt_move;
if (meta->tti->lookup(pos.hash(), &te)) {
tt_move = libchess::Move(te.data_._data.m);
if (tt_move != libchess::constants::MOVE_NONE && !pos.is_legal_move(tt_move))
tt_move = libchess::constants::MOVE_NONE;
else if (te.data_._data.depth >= depth) {
bool use = false;
if (te.data_._data.flags == EXACT)
use = true;
else if (te.data_._data.flags == LOWERBOUND && te.data_._data.score >= beta)
use = true;
else if (te.data_._data.flags == UPPERBOUND && te.data_._data.score <= alpha)
use = true;
if (use && (!is_root_position || tt_move != libchess::constants::MOVE_NONE)) {
*m = tt_move;
return te.data_._data.score;
}
}
}