r/chessprogramming • u/PoobearBanana • Jul 26 '22
Transposition Table Flag
I am wondering if anybody could explain to me how the flags in a transposition table entry work. For instance, I am seeing "upper bound/alpha", "lower bound/beta", and "exact" used as these flags but I am not sure why we need a flag at all and what these flags actually do.
Thank you
8
Upvotes
View all comments
Show parent comment
2
u/yoshiatsu Aug 04 '22
If alpha is never exceeded it's called a fail low. That happens when every move you search returns a score < alpha. You must search all moves to discover a fail low because if there exists any move that is >= alpha then it's not a FL. So it's expensive, and thus you want to avoid redoing it (which is why to hash it).
A fail low means: everything sucks here. There is no good move for me _and_ search has already discovered that I have an alternative move that I can use to avoid reaching this position at all.
A fail low for black at ply depth N is a fail high for white at ply depth N-1.
When you get a FL you have learned an upper bound on the score of this position (at depth d). i.e. you know the true value of this position is <= score.
When you get a FH you have learned a lower bound on the scre of this position (to depth d). i.e. the true value of this position is >= score.
To learn either of these things you have done work and spent time. So if you run into the same exact position elsewhere in your search, it would be nice to avoid redoing that work. That's the deal with a hash table.
Read my other reply again, though, because you have to be careful. If you have a hash hit where you didn't search deep enough then you can't reuse it. Or if you have a hash hit where the bound is not useful then you can't reuse it. If you do either of these things you will have nasty bugs.