Page 1 of 1

Fifty move counter and Null move

Posted: Wed Aug 09, 2017 4:57 pm
by tomitank
Hi!

Senpai and Fruit set the fifty move counter = 0 before null move and copy from history after null move.

Code: Select all

   void move_null() {
     //..........
      p_copy.moves = 0; // HACK: conversion
     //..........
   }
So not detecting draw.

Code: Select all

      for &#40;int i = 4; i < p_copy.moves; i += 2&#41; &#123;
         if &#40;p_stack&#91;p_sp - i&#93;.copy.key == key&#41; &#123;
            return true;
         &#125;
      &#125;
Stockfish and Sungorus increase the fifty move counter by 1 before null move and decrease after null move.

Code: Select all

void Position&#58;&#58;do_null_move&#40;StateInfo& newSt&#41; &#123;
    //..........
  ++st->rule50;
   //...........
&#125;

Code: Select all

  for &#40;int i = 2, e = std&#58;&#58;min&#40;st->rule50, st->pliesFromNull&#41;; i <= e; i += 2&#41;
  &#123;
      stp = stp->previous->previous;

      if &#40;stp->key == st->key&#41;
          return true; // Draw at first repetition
  &#125;

Which one is correct?

I think stockfish and sungorus good, but then "Senpai" is wrong?

Apropo: I do not see this in many engines.

-Tamas

Re: Fifty move counter and Null move

Posted: Wed Aug 09, 2017 5:30 pm
by Robert Pope
Personally, I don't think it makes a lot of sense to zero it with a null move. You haven't done something irreversible like capturing a piece.

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.

Re: Fifty move counter and Null move

Posted: Wed Aug 09, 2017 7:20 pm
by syzygy
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.

Re: Fifty move counter and Null move

Posted: Wed Aug 09, 2017 9:54 pm
by hgm
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.