add Quad Wrangle (#704)
authorRainRat <rainrat78@yahoo.ca>
Fri, 1 Sep 2023 14:19:21 +0000 (07:19 -0700)
committerGitHub <noreply@github.com>
Fri, 1 Sep 2023 14:19:21 +0000 (16:19 +0200)
src/parser.cpp
src/position.cpp
src/types.h
src/variants.ini

index 43d2bc8..348f17f 100644 (file)
@@ -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) {
index 7363fc2..1b8ae90 100644 (file)
@@ -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
index 12de0c6..a59f867 100644 (file)
@@ -302,7 +302,7 @@ enum ChasingRule {
 };
 
 enum EnclosingRule {
-  NO_ENCLOSING, REVERSI, ATAXX
+  NO_ENCLOSING, REVERSI, ATAXX, QUADWRANGLE
 };
 
 enum OptBool {
index 63bd4da..c048132 100644 (file)
 # [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