for (int i = 2, e = std::min(st->rule50, st->pliesFromNull); i <= e; i += 2)
{
stp = stp->previous->previous;
if (stp->key == st->key)
return true; // Draw at first repetition
}
Which one is correct?
I think stockfish and sungorus good, but then "Senpai" is wrong?
Robert Pope wrote:However, since null-moves aren't legal and won't happen in the game, I think it just comes down to which gives better results in matches.
I fully agree.
The Stockfish approach makes the most sense to me:
- do not detect draw-by-repetiion across a nullmove, but
- do detect draw by 50-move rule if no progress is being made even if the current branch includes nullmoves.
But, as already stated, what is best depends on how well it works in real games.
I guess the resetting of the 50-move counter on null move was originally done in engines where this counter also decided how far back in the move history it looks for repetitions. With normal moves you cannot repeat positions from before the last irreversible move. Resetting the counter on null move was just a kludge to use this mechanism for ignoring null-move-spanning repeats. It was not really intended to fool the engine into thinking it could dodge 50-move draws by null-moving.