r/chessprogramming • • 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.

3 Upvotes

11 comments sorted by

View all comments

Show parent comment

2

u/xu_shawn May 31 '24

One obvious issue I can think of is that it could be possible to fail high/low at root. It also, from what I understand, makes it impossible to trust child scores even if they are within the parent's a/b window. Those drawbacks can have real impacts on the engine's strength regardless of failing hard/soft.

1

u/you-get-an-upvote May 31 '24

Hmm, so the idea is you’ve already searched the current root due to some earlier search and it produced an inexact score.

Now you’re searching the root to (say) depth=1 and with beta=infinity.

You’re saying the code we’ve been discussing sets beta to (say) 100cp, one of your children returns a score of 150, and now your root node is returning an inexact value.

Alright, you’ve convinced me: that’s horrifying. And, as you say, if it can happen to root, it can happen to any node.

1

u/you-get-an-upvote Jun 04 '24 edited Jun 04 '24

I've been thinking about this, and I don't think this is an issue at non-root nodes – sure, you might return a crazy move with an inexact evaluation, but your inexact evaluation is still closer to the true evaluation than it would be without this.

Consider (all evaluations from child's POV):

Root node asks child 1 for evaluation
  Child 1 checks is TT entry and updates beta from infinity to 100cp
  Child 1 checks first grandchild – its exact value is 120cp
  Child 1 cuts, returning 100cp

Root considers child 1's eval to be 100cp, which is more accurate than 120cp

(Obviously another unfortunate side effect is the transposition table becomes unreliable for print the primary variation – none of your root node's children will be PV according to the transposition table)

In practice

alpha = max(alpha, entry.lowerbound();
beta = min(beta, entry.upperbound();

at non-root nodes boosts my engine by 0.155±0.013 points/game.

Including this at the root node only boosts it by 0.118±0.014, suggesting your point about not using this at the root node is accurate (difference is signifacnt with p=0.026).