Page 1 of 1

Inconsistent examples of cutoff code

Posted: Sat Feb 11, 2017 11:38 pm
by thevinenator
This has been on my mind for quite sometime and I've been meaning to ask about it in order to finally get a resolution.
Consider the following typical framework...

Code: Select all

   v = -alphabeta( -beta, -alpha...)

   // eventually code gets here...
   if ( v >= beta
      {
      // do cutoff stuff
      saveHash(..., beta, ...);    // in some examples, v is saved
      return beta;   // in some examples, v is returned
      }

   // code continues
I've seen example code where instead of saving and returning beta, 'v' is saved and returned.
It must make a difference, me thinks.

Does it have to do with hard vs soft fail?
If so, which is correct for each case?

Re: Inconsistent examples of cutoff code

Posted: Sun Feb 12, 2017 5:59 pm
by H.G.Muller
Indeed, storing and returning v would be 'fail soft', storing and returning beta is known as 'fail hard'.

Both will work,and without hash table it does not matter what you use, because any result above beta is equivalent. With hash table, however, you might want to use the result when you visit the same position with another beta. Suppose the first time beta=10, and your search returns v=150, a lower limit to the real score. If you stored 10 (beta), and you later have to search the same node with beta = 20 after a transposition, the 10 result would not be useful, and you would need to redo the search. If you had stored 150, the stored result could be used to give you an immediate hash cutoff even when beta = 20. Fail hard destroys information that might be usefull, by storing needlessly pessimistic bounds on the score.