Alexander077 wrote:Hello to everyone. I do not quite understand how works TT. Why do we have to check that the score <= alpha (in case of UpperBound) and score > = beta (in the case of Lower bound)?
Let's take both possible search outcomes.
1. You completely search the current position, and you don't get a fail-high anywhere. You store a TT entry that says "this is an upper bound" and you store the value for alpha. That means you know the score is <= alpha, not greater than, otherwise you would have failed high. Now suppose you reach this same position at some other place in the tree. If the TT entry, which is an upper bound on the score, is <= your current alpha value (lower bound) you can just return alpha and not do a search, because you will again fail low. If your alpha value has changed enough, the tt entry score might not be bad enough to allow you to stop, if the current alpha value is actually < the tt bound, so you get to keep searching. If the tt value is > your current alpha value, that would create a "loop hole" here where the score could be <= the tt score, but > your current alpha, and you should NOT fail low. That's why the test is done for this bound.
2. You partially search (or completely perhaps) search the current position, and you either fail high, or you get a score > alpha. (I am going to ignore the exact score / real score case and just consider the fail-high case). Since you failed high on the tt score, you know that tt score is a lower bound on the real score and that it might actually be higher. If the tt score is >= your current beta value, you can again stop, return beta, and fail high without doing the search. If the tt score is < your current beta value, you have that same "loop hole". The score could be > the tt entry bound, but < your current beta value, and you don't want to fail high here either.
The easy way to think about this is to consider each of the above two cases. If you fail low here this time around, you'd like to fail low the next time you get here, without doing any work, if that is possible. Ditto for a fail high. It is all about "avoiding duplicated work".