From 0907b7f75899949b421ab5b64a4cff8488f504c3 Mon Sep 17 00:00:00 2001 From: RainRat Date: Fri, 1 Sep 2023 07:19:21 -0700 Subject: [PATCH] add Quad Wrangle (#704) --- src/parser.cpp | 3 ++- src/position.cpp | 7 +++++-- src/types.h | 2 +- src/variants.ini | 19 ++++++++++++++++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/parser.cpp b/src/parser.cpp index 43d2bc8..348f17f 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -105,8 +105,9 @@ namespace { template <> bool set(const std::string& value, EnclosingRule& target) { target = value == "reversi" ? REVERSI : value == "ataxx" ? ATAXX + : value == "quadwrangle" ? QUADWRANGLE : NO_ENCLOSING; - return value == "reversi" || value == "ataxx" || value == "none"; + return value == "reversi" || value == "ataxx" || value == "quadwrangle" || value == "none"; } template <> bool set(const std::string& value, Bitboard& target) { diff --git a/src/position.cpp b/src/position.cpp index 7363fc2..1b8ae90 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1675,8 +1675,11 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) { } else { - assert(flip_enclosed_pieces() == ATAXX); - st->flippedPieces = PseudoAttacks[us][KING][to] & pieces(~us); + assert((flip_enclosed_pieces() == ATAXX) || (flip_enclosed_pieces() == QUADWRANGLE)); + if ((flip_enclosed_pieces() == ATAXX) || (flip_enclosed_pieces() == QUADWRANGLE && (PseudoAttacks[us][KING][to] & pieces(us) || type_of(m) == NORMAL))) + { + st->flippedPieces = PseudoAttacks[us][KING][to] & pieces(~us); + } } // Flip pieces diff --git a/src/types.h b/src/types.h index 12de0c6..a59f867 100644 --- a/src/types.h +++ b/src/types.h @@ -302,7 +302,7 @@ enum ChasingRule { }; enum EnclosingRule { - NO_ENCLOSING, REVERSI, ATAXX + NO_ENCLOSING, REVERSI, ATAXX, QUADWRANGLE }; enum OptBool { diff --git a/src/variants.ini b/src/variants.ini index 63bd4da..c048132 100644 --- a/src/variants.ini +++ b/src/variants.ini @@ -129,7 +129,7 @@ # [MaterialCounting]: material counting rules for adjudication [janggi, unweighted, whitedrawodds, blackdrawodds, none] # [CountingRule]: makruk, cambodian, or ASEAN counting rules [makruk, cambodian, asean, none] # [ChasingRule]: xiangqi chasing rules [axf, none] -# [EnclosingRule]: reversi or ataxx enclosing rules [reversi, ataxx, none] +# [EnclosingRule]: reversi or ataxx enclosing rules [reversi, ataxx, quadwrangle, none] ### Additional options relevant for usage in Winboard/XBoard # A few options only have the purpose of improving compatibility with Winboard/Xboard. @@ -1594,3 +1594,20 @@ customPiece1 = p:fmWfceFifmnD pawnTypes = p petrifyOnCapture = true enPassantRegion = - + +#https://www.ludii.games/details.php?keyword=Quad%20Wrangle +[quadwrangle:ataxx] +#different sources give different info on whether it is a 7x7 or 8x8 board. +#could offer both if wanted. +maxRank = 8 +maxFile = 8 +startFen = 1PPPPPP1/p6P/p6P/p6P/p6P/p6P/p6P/1pppppp1 +customPiece1 = p:mQ +flipEnclosedPieces = quadwrangle +#override rule from ataxx since drops can be done freely +enclosingDrop = none + +[quadwrangle7x7:quadwrangle] +maxRank = 7 +maxFile = 7 +startFen = 1PPPPP1/p5P/p5P/p5P/p5P/p5P/1ppppp1 -- 1.7.0.4