Code: Select all
tentry_t *ttable_t::probe(int alpha, int beta, int depth, uint64_t key)
{
tentry_t *te = &table[key % tt_size];
if (te->key == key && te->depth >= depth) {
if (te->bound == lower_bound && te->score >= beta)
te->score = beta;
if (te->bound == upper_bound && te->score <= alpha)
te->score = alpha;
return te;
}
return nullptr;
}
Code: Select all
int negamax(alpha, beta, ...)
{
bound = upper_bound;
for each move {
....
if (score >= beta) {
tt.store(beta, depth, lower_bound, board.hash());
return beta;
}
if (score > alpha) {
alpha = score;
bound = exact_bound;
pv = std::move(child_pv);
pv.insert(pv.begin(), move);
}
}
tt.store(alpha, depth, bound, board.hash());
return alpha;
}
the TT starts to work when i do this in probe()
Code: Select all
if ((te->bound == lower_bound && te->score >= beta)
|| (te->bound == upper_bound && te->score <= alpha))
return te;
i also don't see the usual behavior of the TT (with the fail-soft probing) where, after searching to let's say a depth of 8, it doesn't skip directly to 8 when researching the same position again. it's only halving the time it took in the first search. i'm using a TT of 256 mb.
after hash() which generates the board hash key from scratch this is the only code i added so i don't really know what else to do.
any help is appreciated, thanks in advance.