bizarre repetition detection issue

Discussion of chess software programming and technical issues.

Moderator: Ras

Ralph Stoesser
Posts: 408
Joined: Sat Mar 06, 2010 9:28 am

Re: bizarre repetition detection issue

Post by Ralph Stoesser »

bob wrote:
Ralph Stoesser wrote:
bob wrote:
The short answer is that SF does not look back beyond the null-move when doing repetition detection.
I have changed SF to look back beyond null-move. I've also tried the additional 4 plies from null limit (don't test for rep draw if plies-from-null < 4).

Both variants have played slightly weaker than default SF, but the results were well within the error margin (-4 Elo and -2 Elo). I've played only 2000 games each version.
I just finished a calibration run for 23.4, and am now re-adding in the 50-move counter limit for 23.5. I am going to run this test and then report the results. This simply uses the 50-move counter as a limit on how far back one can hunt for a repetition, and since Crafty resets the 50 move counter (SF does not, but has a separate counter for moves since a null was played) after a null, the two programs will be doing exactly the same thing. I have tested this more than once and found an Elo drop-off. This time I will report the results here once the test finishes this afternoon some time...
Probably not much Elo to gain here. But interesting anyway.
I am not sure why they maintain two counters, a 50-move counter and a moves-since-null counter. If repetitions previous to a null are ignored, I am not sure one would want to deal with 50 move draws since nulls are not going to make much sense there either...
As would seem natural they use the 50-move counter for 50 move rule tests.
And they use the plies-from-null counter for counting the plies from last null move.
I'd say it's easy to understand. :)
Also, IIRC, the stockfish starting point is ply - 4 so it is already excluding the first 4 plies, whether by design or by accident is unknown. Normally you would start looking 4 plies back since you can't repeat any sooner, but null-move changes that and you can repeat sooner than that...

Perhaps we both found the "optimal value" quite by accident... Still testing however...
The starting point is i=4 and the for-loop is ascending. If plies-from-null==4 and 50-move-counter>4 then they test the actual position against the position after the last null move. No null moves in between.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: bizarre repetition detection issue

Post by bob »

Ralph Stoesser wrote:
bob wrote:
Ralph Stoesser wrote:
bob wrote:
The short answer is that SF does not look back beyond the null-move when doing repetition detection.
I have changed SF to look back beyond null-move. I've also tried the additional 4 plies from null limit (don't test for rep draw if plies-from-null < 4).

Both variants have played slightly weaker than default SF, but the results were well within the error margin (-4 Elo and -2 Elo). I've played only 2000 games each version.
I just finished a calibration run for 23.4, and am now re-adding in the 50-move counter limit for 23.5. I am going to run this test and then report the results. This simply uses the 50-move counter as a limit on how far back one can hunt for a repetition, and since Crafty resets the 50 move counter (SF does not, but has a separate counter for moves since a null was played) after a null, the two programs will be doing exactly the same thing. I have tested this more than once and found an Elo drop-off. This time I will report the results here once the test finishes this afternoon some time...
Probably not much Elo to gain here. But interesting anyway.
I am not sure why they maintain two counters, a 50-move counter and a moves-since-null counter. If repetitions previous to a null are ignored, I am not sure one would want to deal with 50 move draws since nulls are not going to make much sense there either...
As would seem natural they use the 50-move counter for 50 move rule tests.
And they use the plies-from-null counter for counting the plies from last null move.
I'd say it's easy to understand. :)
Also, IIRC, the stockfish starting point is ply - 4 so it is already excluding the first 4 plies, whether by design or by accident is unknown. Normally you would start looking 4 plies back since you can't repeat any sooner, but null-move changes that and you can repeat sooner than that...

Perhaps we both found the "optimal value" quite by accident... Still testing however...
The starting point is i=4 and the for-loop is ascending. If plies-from-null==4 and 50-move-counter>4 then they test the actual position against the position after the last null move. No null moves in between.
The for-loop is ascending, but the array accesses are not:

Code: Select all

  for (int i = 4, e = Min(Min(st->gamePly, st->rule50), st->pliesFromNull); i <= e; i += 2)
      if (history[st->gamePly - i] == st->key)
                  ^^^^^^^^^^^^^^^
          return true;
that -i makes it walk from the current ply (-4) backward, which effectively disregards the first 4 potential repetitions (2 for either side) after a null... If you make a null, the program will not test any of the 4 possible (2 for each side) positions following that null for a rep, if I am reading their code correctly.

One would not want to talk the replist forward, because repetitions tend to occur with positions near the end, not near the front.[/b]