From 088d4da202fec1792c336671813a2521c600f28b Mon Sep 17 00:00:00 2001 From: Fabian Fichter Date: Thu, 19 May 2022 20:12:47 +0200 Subject: [PATCH] Update 50 move rule for xiangqi Closes #405. --- src/position.cpp | 22 ++++++++++++++++++++-- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 1e0d2fc..eaa37d6 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -2314,8 +2314,26 @@ bool Position::is_optional_game_end(Value& result, int ply, int countStarted) co // n-move rule if (n_move_rule() && st->rule50 > (2 * n_move_rule() - 1) && (!checkers() || MoveList(*this).size())) { - result = var->materialCounting ? convert_mate_value(material_counting_result(), ply) : VALUE_DRAW; - return true; + int offset = 0; + if (var->chasingRule == AXF_CHASING && st->pliesFromNull >= 20) + { + int end = std::min(st->rule50, st->pliesFromNull); + StateInfo* stp = st; + int checkThem = bool(stp->checkersBB); + int checkUs = bool(stp->previous->checkersBB); + for (int i = 2; i < end; i += 2) + { + stp = stp->previous->previous; + checkThem += bool(stp->checkersBB); + checkUs += bool(stp->previous->checkersBB); + } + offset = 2 * std::max(std::max(checkThem, checkUs) - 10, 0) + 20 * (CurrentProtocol == UCCI || CurrentProtocol == UCI_CYCLONE); + } + if (st->rule50 - offset > (2 * n_move_rule() - 1)) + { + result = var->materialCounting ? convert_mate_value(material_counting_result(), ply) : VALUE_DRAW; + return true; + } } // n-fold repetition -- 1.7.0.4