official-stockfish/Stockfish — pull request #80 by promaret (2014-10-27 16:46:42+00:00)
Title: fixing draw detection by checking for 3-fold rep on root moves

This patch fixes the detection of draws by 3-fold repetition.

A recurring complaint is that Stockfish evaluates as drawn a position that repeats for the first time, even though a draw cannot be claimed. There have been several unsuccessful attempts at correcting this. The latest to date (in August) showed a regression of -2.37 Elo +- 1.8.

This pull request pursues the same idea (2-fold detection in search, 3-fold at the root move) but with a simpler implementation. There is no measurable overhead: it only adds 1 pointer comparison per is_draw() call on non-repeated positions; 1 ptr comparison + 1 boolean check on repeated positions except the root moves.

The bench does not change, since benchmark positions are FEN strings (root moves have no past positions to repeat). There is however a small cost in Elo, in the order of -0.5 Elo, probably due to not discarding first-repeating root moves up-front.

The patch passed no-regression STC test, but failed LTC after many games.

At 15+0.05:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 89417 W: 18169 L: 18175 D: 53073

At 60+0.05:
LLR: -2.96 (-2.94,2.94) [-3.00,1.00]
Total: 171356 W: 29121 L: 29556 D: 112679

The small negative Elo may be worth accepting, considering the benefits of a reliable evaluation of repeating moves. Stockfish is used on several prominent websites for live coverage of tournaments. It may raise eyebrows when Stockfish evaluates a winning position as 0.00. For a recent example, see Caruana's 26th move in Baku 2014, round 4, against Mamedyarov. Stockfish reports 26.Ke2 as a blunder, dropping from +2.72 to 0.00. https://arena.chessdom.com/#/game/stream/52952
Interestingly, Komodo exhibits the same issue, while Houdini does not.

A 40K games test run may be scheduled if an Elo measurement is preferable to help approve the patch or not.