Code: Select all
if (value > bestValue)
{
bestValue = value;
if (value > alpha)
{Moderators: hgm, Dann Corbit, Harvey Williamson
Code: Select all
if (value > bestValue)
{
bestValue = value;
if (value > alpha)
{It's fail-soft. That's where you would have found it.flok wrote:No; must've been a website/wiki somewhere.
The only code I copied from an other chess-program is a 1-liner from fairymax for calculating how much time to allocate for a move.
The OP didn't write it. Look at the original code snippet. It was a comment added by Robert.kbhearn wrote:then why'd you write it?
the break in this case does something outside the scope of the quoted code - it removes you from the innermost loop you're currently in perhaps to the final 'return bestVal;' line (which you now have scored as the current score > beta). It may avoid some code duplication if the TT update is similar enough for the fail high and fail low cases to write it in this manner.
This is how computer chess works these days.flok wrote: copy/paste from somewhere
Don't whine. There are plenty of other things to focus on while implementing a chess program that are far more interesting than the 1000th implementation of what we're discussing here.Joost Buijs wrote:This is how computer chess works these days.flok wrote: copy/paste from somewhere
At least I would expect some understanding about what you copy/paste.flok wrote:Don't whine. There are plenty of other things to focus on while implementing a chess program that are far more interesting than the 1000th implementation of what we're discussing here.Joost Buijs wrote:This is how computer chess works these days.flok wrote: copy/paste from somewhere
What "loop" ?flok wrote:beta cut-off; stop the loop and return the best bestval.Robert wrote:Code: Select all
if (score > bestVal) { bestVal = score; // remember move for sibling-node-best-move selMove = *newCause.causingMove; if (score > alpha) { alpha = score; // remember PV newPv.assign(tempPv, false); if (score >= beta) break; <= I don't understand This!!! } }
There is implicitly - you need a move loop to traverse all the moves, no?Robert wrote:Hi Folkert,
What "loop" ?flok wrote:beta cut-off; stop the loop and return the best bestval.Robert wrote:Code: Select all
if (score > bestVal) { bestVal = score; // remember move for sibling-node-best-move selMove = *newCause.causingMove; if (score > alpha) { alpha = score; // remember PV newPv.assign(tempPv, false); if (score >= beta) break; <= I don't understand This!!! } }
There are no loops in this code.
As HGM stated, it depends on the search algorithm you are using.flok wrote:I wonder why is there a if (score > bestval) and also a if (score > alpha)?
Because if > bestval then always also > alpha.