]> git.sesse.net Git - stockfish/commit
Fix cycle detection in presence of repetitions
authorSergei Ivanov <srg.ivanov@gmail.com>
Sun, 14 Apr 2019 12:50:37 +0000 (15:50 +0300)
committerStéphane Nicolet <cassio@free.fr>
Thu, 9 May 2019 13:39:57 +0000 (15:39 +0200)
commitad8b78ad5281138cfe188dedcf76ec8ef622531f
tree88bf617407931bb61d1035be8df93a29555ef8be
parent368f976fb6fc9096d7f19b0443fb4d1af40eec14
Fix cycle detection in presence of repetitions

In master search() may incorrectly return a draw score in the following
corner case: there was a 2-fold repetition during the game, and the
current position can be reached by a move from a repeated one. This case
is treated as an upcoming 3-fold repetition, which it is not.

Here is a testcase demonstrating the issue (note that the moves
after FEN are required). The input:

  position fen 8/8/8/8/8/8/p7/2k4K b - - 0 1 moves c1b1 h1g1 b1c1 g1h1 c1b1 h1g1 b1a1 g1h1
  go movetime 1000

produces the output:

  [...]
  info depth 127 seldepth 2 multipv 1 score cp 0 [...]
  bestmove a1b1

saying that the game will be drawn by repetion. However the other possible
move for black, Kb2, avoids repetitions and wins. The patch fixes this behavior.
In particular it finds mate in 10 in the above position.

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 10604 W: 2390 L: 2247 D: 5967
http://tests.stockfishchess.org/tests/view/5cb373e00ebc5925cf0167bf

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 19620 W: 3308 L: 3185 D: 13127
http://tests.stockfishchess.org/tests/view/5cb3822f0ebc5925cf016b2d

Bench is not changed since it does not test positions with history of moves.

Bench: 3184182
src/position.cpp