From: Fabian Fichter Date: Fri, 24 Apr 2020 11:00:00 +0000 (+0200) Subject: Support all common Janggi rule sets X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=25fb504e97688693591c516dd2f36550e7b47161;p=fairystockfish.git Support all common Janggi rule sets * Tournament rules with material counting * Traditional rules with bikjang as draw * Casual rules without bikjang Closes #101. --- diff --git a/src/parser.cpp b/src/parser.cpp index cc12034..33261c8 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -70,15 +70,16 @@ namespace { template <> bool set(const std::string& value, Value& target) { target = value == "win" ? VALUE_MATE : value == "loss" ? -VALUE_MATE - : VALUE_DRAW; - return value == "win" || value == "loss" || value == "draw"; + : value == "draw" ? VALUE_DRAW + : VALUE_NONE; + return value == "win" || value == "loss" || value == "draw" || value == "none"; } template <> bool set(const std::string& value, CountingRule& target) { target = value == "makruk" ? MAKRUK_COUNTING : value == "asean" ? ASEAN_COUNTING : NO_COUNTING; - return value == "makruk" || value == "asean" || value == ""; + return value == "makruk" || value == "asean" || value == "none"; } template <> bool set(const std::string& value, Bitboard& target) { diff --git a/src/variant.cpp b/src/variant.cpp index c5ce97b..f98ab93 100644 --- a/src/variant.cpp +++ b/src/variant.cpp @@ -879,12 +879,18 @@ namespace { v->perpetualCheckIllegal = true; return v; } - // Casual rules of Janggi, where bikjang is a draw - Variant* janggi_casual_variant() { + // Traditional rules of Janggi, where bikjang is a draw + Variant* janggi_traditional_variant() { Variant* v = janggi_variant(); v->bikjangValue = VALUE_DRAW; return v; } + // Casual rules of Janggi, where bikjang is not considered + Variant* janggi_casual_variant() { + Variant* v = janggi_variant(); + v->bikjangValue = VALUE_NONE; + return v; + } #endif } // namespace @@ -969,6 +975,7 @@ void VariantMap::init() { add("manchu", manchu_variant()); add("supply", supply_variant()); add("janggi", janggi_variant()); + add("janggitraditional", janggi_traditional_variant()); add("janggicasual", janggi_casual_variant()); #endif } diff --git a/src/variants.ini b/src/variants.ini index 0e5b805..fbeb167 100644 --- a/src/variants.ini +++ b/src/variants.ini @@ -107,8 +107,8 @@ # promotionRank: relative rank required to reach for promotion [Rank] (default: 8) # promotionPieceTypes: pawn promotion options using their one-letter representations (default: nbrq) # sittuyinPromotion: enable Sittuyin-style pawn promotion [bool] (default: false) -# promotionLimit: maximum number of pieces of a type, e.g., q:1 r:2 (default: ) -# promotedPieceType: mapping between unpromoted and promoted non-pawn piece types, e.g., p:g s:g (default: ) +# promotionLimit: maximum number of pieces of a type, e.g., q:1 r:2 (default: ) +# promotedPieceType: mapping between unpromoted and promoted non-pawn piece types, e.g., p:g s:g (default: ) # piecePromotionOnCapture: piece promotion only allowed on captures (e.g., micro shogi) [bool] (default: false) # mandatoryPawnPromotion: pawn promotion is mandatory [bool] (default: true) # mandatoryPiecePromotion: piece promotion (and demotion if enabled) is mandatory [bool] (default: false) @@ -160,20 +160,20 @@ # checkmateValue: result in case of checkmate [Value] (default: loss) # shogiPawnDropMateIllegal: prohibit checkmate via shogi pawn drops [bool] (default: false) # shatarMateRule: enable shatar mating rules [bool] (default: false) -# bikjangValue: result in case of Janggi bikjang (facing kings) for the player with more points [Value] (default: ) -# bareKingValue: result when player only has a lone/bare king [Value] (default: ) -# extinctionValue: result when one of extinctionPieceTypes is extinct [Value] (default: ) +# bikjangValue: result in case of Janggi bikjang (facing kings) for the player with more points [Value] (default: none) +# bareKingValue: result when player only has a lone/bare king [Value] (default: none) +# extinctionValue: result when one of extinctionPieceTypes is extinct [Value] (default: none) # bareKingMove: allow additional move by opponent after lone/bare king position [bool] (default: false) -# extinctionPieceTypes: list of piece types for extinction rules, e.g., pnbrq (* means all) (default: ) +# extinctionPieceTypes: list of piece types for extinction rules, e.g., pnbrq (* means all) (default: ) # extinctionPieceCount: piece count at which the game is decided by extinction rule (default: 0) # extinctionOpponentPieceCount: opponent piece count required to adjudicate by extinction rule (default: 0) -# flagPiece: piece type for capture the flag win rule [PieceType] (default: ) -# whiteFlag: white's target region for capture the flag win rule [Bitboard] (default: ) -# blackFlag: black's target region for capture the flag win rule [Bitboard] (default: ) +# flagPiece: piece type for capture the flag win rule [PieceType] (default: -) +# whiteFlag: white's target region for capture the flag win rule [Bitboard] (default: ) +# blackFlag: black's target region for capture the flag win rule [Bitboard] (default: ) # flagMove: black gets one more move after white captures the flag [bool] (default: false) # checkCounting: enable check count win rule (check count is communicated via FEN, see 3check) [bool] (default: false) # connectN: number of aligned pieces for win [int] (default: 0) -# countingRule: enable counting rules [CountingRule] (default: ) +# countingRule: enable counting rules [CountingRule] (default: none) ################################################ ### Example for minishogi configuration that would be equivalent to the built-in variant: