From e6f2d43b8a02aeb0180466d75be425800ec7c24d Mon Sep 17 00:00:00 2001 From: Joona Kiiski Date: Wed, 24 Feb 2010 20:13:35 +0200 Subject: [PATCH 1/1] Fix repetition detection bug Bug spotted by Jouni Uski and fix suggested by Pablo Vazquez Also add note that we are not always handling fifty move rule correctly Signed-off-by: Marco Costalba --- src/position.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/position.cpp b/src/position.cpp index 2508db66..0336a832 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1678,6 +1678,7 @@ Value Position::compute_non_pawn_material(Color c) const { /// Position::is_draw() tests whether the position is drawn by material, /// repetition, or the 50 moves rule. It does not detect stalemates, this /// must be done by the search. +// FIXME: Currently we are not handling 50 move rule correctly when in check bool Position::is_draw() const { @@ -1691,7 +1692,7 @@ bool Position::is_draw() const { return true; // Draw by repetition? - for (int i = 2; i < Min(Min(gamePly, st->rule50), st->pliesFromNull); i += 2) + for (int i = 4; i <= Min(Min(gamePly, st->rule50), st->pliesFromNull); i += 2) if (history[gamePly - i] == st->key) return true; -- 2.39.2