From 97796714499dc2d3cf111fbb55b0fb01adbb7498 Mon Sep 17 00:00:00 2001 From: Fabian Fichter Date: Sat, 16 Nov 2019 18:00:58 +0100 Subject: [PATCH] Add xiangqihouse to variants.ini Enhance bitboard parsing to simplify definition. --- src/parser.cpp | 7 ++++--- src/variant.cpp | 2 ++ src/variants.ini | 10 +++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/parser.cpp b/src/parser.cpp index 427faf7..4e86dbf 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -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 diff --git a/src/variant.cpp b/src/variant.cpp index 3753153..0e2daf3 100644 --- a/src/variant.cpp +++ b/src/variant.cpp @@ -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'); diff --git a/src/variants.ini b/src/variants.ini index 49c0440..bd27721 100644 --- a/src/variants.ini +++ b/src/variants.ini @@ -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 -- 1.7.0.4