From: Fabian Fichter Date: Mon, 4 Mar 2019 19:22:44 +0000 (+0100) Subject: Implement sittuyin stalemate rule (#14) X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=cca5d56e33e8cc0cf06938abb0269aff0a7ce96f;p=fairystockfish.git 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. --- 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; }