From f7bae2de82347c61897b8de62d294dd0e4fc579e Mon Sep 17 00:00:00 2001 From: joergoster Date: Fri, 1 Jun 2018 22:35:23 +0200 Subject: [PATCH] Bugfix of Position::has_repeated() The function Position::has_repeated() is used by Tablebases::root_probe() to determine whether we can rank all winning moves with the same value, or if we need to strictly rank by dtz in case the position has already been repeated once, and we are risking to run into the 50-move rule and thus losing the win (especially critical in some very complicated endgames). To check whether the current position or one of the previous positions after the last zeroing move has already been occured once, we start looking for a repetition of the current position, and if that is not the case, we step one position back and repeat the check for that position, and so on. If you now look at how this was done before the new root ranking patch was merged two months ago, it seems quite obvious that it is a simple oversight: https://github.com/official-stockfish/Stockfish/commit/108f0da4d7f993732aa2e854b8f3fa8ca6d3b46c More specifically, after we stepped one position back with ``` stc = stc->previous; ``` we now have to start checking for a repetition with ``` StateInfo* stp = stc->previous->previous; ``` and not with ``` StateInfo* stp = st->previous->previous; ``` Closes https://github.com/official-stockfish/Stockfish/pull/1625 No functional change --- src/position.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/position.cpp b/src/position.cpp index 8dedce41..2573fe84 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1153,7 +1153,7 @@ bool Position::has_repeated() const { if (end < i) return false; - StateInfo* stp = st->previous->previous; + StateInfo* stp = stc->previous->previous; do { stp = stp->previous->previous; -- 2.39.2