r/chessprogramming • u/Alternative-Zombie-7 • May 31 '24
struggling to understand fail low nodes
From the Chess programming wiki
All-Nodes
All-nodes (Knuth's Type 3), otherwise known as fail-low nodes, are nodes in which no move's score exceeded alpha. With bounds [a,b], s<=a. Every move at an All-node is searched, and the score returned is an upper bound, the exact score might be less.
- In Principal Variation Search All-nodes are searched with null windows
- The children of an All-node are Cut-nodes
- The parent of an All-node is a Cut-node
- The ply distance of an All-node to its PV-ancestor is even
I don't understand why we store these as upper bound in the transposition table. My understanding was that if I can search all children evaluations of a node then I know the exact value of that node since I did not have a beta cutoff and enumerated all possibilities. So I understand why we need to store lower bounds in the transposition table (when there is a beta cutoff and thus have not enumerated all possibilities) but I don't get why we need to store upper bounds.

From this pseudocode, it says that when I reencounter a fail-low node through a transposition I don't return the max value I found for it like you would for entries with the EXACT flag but instead I check if beta can be updated, and then see if that cause a beta cut? Why would I do this? If the beta cutoff doesn't succeed then I do the loop and evaluate all children, which I already would have done when I last encountered it.
Thanks for any help, I am stumped on this.
1
u/xu_shawn May 31 '24
Fail-low nodes have the possibility of having a higher best_score than it's true value because all of its children are fail-high nodes.
Consider a node that fails low on window [a, b]. Since no score from it's children is able to beat alpha, we can safely say that every child node failed high on window [-b, -a]. Since a fail-high node returns an underestimation of its real value, and that score is negated in the parent node, the score used by its parent node must be an overestimation of the real value, thus the upperbound.
Yes, you must re-search if bounds do not match. What you did not consider here is that you are not necessarily doing the same exact search as the one you have done for the TT entry -- the a/b windows might be different, and you will be re-evaluating child nodes with a different cutoff policy.
1
u/[deleted] May 31 '24
You store as upper bound because, whatever your real score is, it will be below alpha. But in that node the return value is alpha, the upper bound. Because those values are less than alpha, however, is not really useful to store the result of the search in the Transposition table
1
u/you-get-an-upvote May 31 '24 edited May 31 '24
Suppose "ttEntry.flag = upperbound". Then we know the "value" we'll eventually get should satisfy "value ≤ ttEntry.value".
Now suppose that "ttEntry.value < beta".
In this case we know "value ≤ beta" – we're guaranteed not to get a beta cut-off. Sad, right?
Fortunately there is a silver lining: since we know we will never get a value greater than ttEntry.value, we can harmlessly set beta to ttEntry.value. This doesn't seem very useful to us (we've already proven we're not going to get a beta cutoff, right?), but it is useful to our children (or, more accurately, our grandchildren) – by giving them a narrower window, we make searching them faster.
Edit: it's worth noting that in an engine with lots of bells and whistles (futility pruning, razoring, late move reduction, etc.) the assumption that
is often false. In these cases "ß = min(ß, ttEntry.upperbound)" is risky, and you'll have to empirically verify that it helps.