Support all common Janggi rule sets
authorFabian Fichter <ianfab@users.noreply.github.com>
Fri, 24 Apr 2020 11:00:00 +0000 (13:00 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Fri, 24 Apr 2020 11:00:00 +0000 (13:00 +0200)
* Tournament rules with material counting
* Traditional rules with bikjang as draw
* Casual rules without bikjang

Closes #101.

src/parser.cpp
src/variant.cpp
src/variants.ini

index cc12034..33261c8 100644 (file)
@@ -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) {
index c5ce97b..f98ab93 100644 (file)
@@ -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
 }
index 0e5b805..fbeb167 100644 (file)
 # 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: <none>)
-# promotedPieceType: mapping between unpromoted and promoted non-pawn piece types, e.g., p:g s:g (default: <none>)
+# 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)
 # 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: <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>)
+# 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: <none>)
+# 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: <none>)
-# whiteFlag: white's target region for capture the flag win rule [Bitboard] (default: <none>)
-# blackFlag: black's target region for capture the flag win rule [Bitboard] (default: <none>)
+# 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: <none>)
+# countingRule: enable counting rules [CountingRule] (default: none)
 
 ################################################
 ### Example for minishogi configuration that would be equivalent to the built-in variant: