From cca5d56e33e8cc0cf06938abb0269aff0a7ce96f Mon Sep 17 00:00:00 2001 From: Fabian Fichter Date: Mon, 4 Mar 2019 20:22:44 +0100 Subject: [PATCH] Implement sittuyin stalemate rule (#14) Taking a promotion to avoid stalemate is optional (rule 3.9 c.7). Example: setoption name multipv value 20 setoption name UCI_Variant value sittuyin position fen k5PK/3r4/8/8/8/8/8/8 b - - 0 1 go depth 1 No functional change for other variants. --- src/position.cpp | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 7c6c007..3aa68ef 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1605,6 +1605,26 @@ bool Position::is_optional_game_end(Value& result, int ply) const { return true; } + // sittuyin stalemate due to optional promotion (3.9 c.7) + if ( sittuyin_promotion() + && count(sideToMove) == 2 + && count(sideToMove) == 1 + && !checkers()) + { + bool promotionsOnly = true; + for (const auto& m : MoveList(*this)) + if (type_of(m) != PROMOTION) + { + promotionsOnly = false; + break; + } + if (promotionsOnly) + { + result = VALUE_DRAW; + return true; + } + } + return false; } -- 1.7.0.4