Inconsistent examples of cutoff code

Code, algorithms, languages, construction...

Inconsistent examples of cutoff code

Postby thevinenator » Sat Feb 11, 2017 11:38 pm

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?
"An Engine's strength flows from the Search. But beware, pruning, extensions, reductions; the dark side of the Search are they. Once you start down the dark path, it will dominate and consume you, as it has to so many developers before.” -- Yoda
Posts: 68
Joined: Tue Jun 02, 2015 11:02 pm

Re: Inconsistent examples of cutoff code

Postby H.G.Muller » Sun Feb 12, 2017 5:59 pm

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.
Posts: 179
Joined: Sun Jul 14, 2013 10:00 am

Return to Programming and Technical Discussions

Who is online

Users browsing this forum: No registered users and 1 guest