Add xiangqihouse to variants.ini
authorFabian Fichter <ianfab@users.noreply.github.com>
Sat, 16 Nov 2019 17:00:58 +0000 (18:00 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sat, 16 Nov 2019 17:00:58 +0000 (18:00 +0100)
Enhance bitboard parsing to simplify definition.

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

index 427faf7..4e86dbf 100644 (file)
@@ -75,11 +75,12 @@ namespace {
     }
 
     template <> void set(const std::string& value, Bitboard& target) {
-        char token, token2;
+        char file;
+        int rank;
         std::stringstream ss(value);
         target = 0;
-        while (ss >> token && ss >> token2)
-            target |= make_square(File(tolower(token) - 'a'), Rank(token2 - '1'));
+        while (ss >> file && ss >> rank)
+            target |= file == '*' ? rank_bb(Rank(rank - 1)) : square_bb(make_square(File(tolower(file) - 'a'), Rank(rank - 1)));
     }
 
 } // namespace
index 3753153..0e2daf3 100644 (file)
@@ -249,6 +249,7 @@ namespace {
     }
     Variant* pocketknight_variant() {
         Variant* v = fairy_variant_base();
+        v->pocketSize = 2;
         v->startFen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR[Nn] w KQkq - 0 1";
         v->pieceDrops = true;
         v->capturesToHand = false;
@@ -722,6 +723,7 @@ namespace {
     }
     Variant* xiangqi_variant() {
         Variant* v = minixiangqi_variant();
+        v->pieceToCharTable = "PN.R.AB..K.C..........pn.r.ab..k.c..........";
         v->maxRank = RANK_10;
         v->maxFile = FILE_I;
         v->add_piece(ELEPHANT, 'b', 'e');
index 49c0440..bd27721 100644 (file)
@@ -87,7 +87,7 @@
 # [File]: denotes a file of the board [1-12, a-i]
 # [int]: any natural number [0, 1, ...]
 # [PieceType]: a piece type [letters defined for pieces, e.g., p]
-# [Bitboard]: list of squares [e.g., d4 e4 d5 e5]
+# [Bitboard]: list of squares [e.g., d4 e4 d5 e5]. * can be used as wildcard for files (e.g., *1 is the first rank)
 # [Value]: game result for the side to move [win, loss, draw]
 # [CountingRule]: makruk or ASEAN counting rules [makruk, asean, none]
 
@@ -207,6 +207,13 @@ mustCapture = true
 pieceDrops = true
 capturesToHand = true
 
+# Hybrid variant of xiangqi and crazyhouse
+[xiangqihouse:xiangqi]
+pieceDrops = true
+capturesToHand = true
+whiteDropRegion = *1 *2 *3 *4 *5
+blackDropRegion = *6 *7 *8 *9 *10
+
 # Hybrid variant of antichess and losalamos
 [anti-losalamos]
 pawn = p
@@ -229,6 +236,7 @@ extinctionPieceTypes = *
 # Indian great chess
 # https://www.chessvariants.com/historic.dir/indiangr1.html
 [indiangreat]
+pieceToCharTable = PNBRQ..VW.........G..Kpnbrq..vw.........g..k
 pawn = p
 knight = n
 bishop = b