2

I have written a chess engine over the last year. Inside my search function I have the following

struct transposition *e = attempt_get(pos);
if (e && transposition_depth(e) >= depth && !(*pv_flag)) {
    /* pv */
    if (transposition_type(e) == 0)
        return transposition_evaluation(e);
    /* cut */
    else if (transposition_type(e) == 1) {
        if (transposition_evaluation(e) >= beta)
            return beta;
    }
    /* all */
    else if (transposition_type(e) == 2) {
        if (transposition_evaluation(e) <= alpha)
            return alpha;
        }
    }
}

The logic seems correct to me. If a transposition caused a beta cutoff and I store it in the transposition table with value beta, then I know that it actually has an evaluation of beta or higher. So if this saved value is greater than beta (when accessing the transposition table) I should be able to return beta.

However removing the two last if statements keeping only

struct transposition *e = attempt_get(pos);
if (e && transposition_depth(e) >= depth && !(*pv_flag)) {
    /* pv */
    if (transposition_type(e) == 0)
        return transposition_evaluation(e);
}

raises the ELO significantly. I let my computer play 1000 games with my engine vs itself where one of them had the lines commented out. The engine without the last lines won significantly more. 602 wins 275 losses and 123 stalemates.

This is not only true for my engine but also for the instructive engine https://github.com/maksimKorzh/bbc. I have only done a test of 500 games this far. I'm currently waiting for more results from the second batch. The results for the first 500 games were about the same. 270 wins 119 losses and 111 stalemates for the engine with commented lines.

The time control for all the games were wtime 120000 btime 120000 winc 1000 binc 1000.

Is something wrong with my (our) logic? Should I be looking for other bugs in my transposition table?

It is also worth mentioning that if I let my engine play without transposition table it loses all 100 games vs itself (with transposition table). So the transposition table is mostly right whatever that means.

My github repo is https://github.com/spinosarus123/bitbit. These final changes are however not commited yet.

1
  • Looks strange. I think it's because you return the exact score stored in the TT, even if the score il outside the bounds of the AB window. Exact score is always better, even if outside the bounds. This score outside the bounds will probably be cut by the search, but it can also save time (no need to test all the conditions). May 15, 2023 at 19:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.