add All Queens, Rooksquare, Alapo, A Simple Game, Picaria, Nine Holes (#652)
authorRainRat <rainrat78@yahoo.ca>
Tue, 2 May 2023 20:08:28 +0000 (13:08 -0700)
committerGitHub <noreply@github.com>
Tue, 2 May 2023 20:08:28 +0000 (22:08 +0200)
src/evaluate.cpp
src/parser.cpp
src/position.cpp
src/position.h
src/syzygy/tbprobe.h
src/variant.h
src/variants.ini

index 1062912..734d117 100644 (file)
@@ -1280,7 +1280,22 @@ namespace {
     // Connect-n
     if (pos.connect_n() > 0)
     {
-        for (Direction d : {NORTH, NORTH_EAST, EAST, SOUTH_EAST})
+        std::vector<Direction> connect_directions;
+
+        if (pos.connect_horizontal())
+        {
+            connect_directions.push_back(EAST);
+        }
+        if (pos.connect_vertical())
+        {
+            connect_directions.push_back(NORTH);
+        }
+        if (pos.connect_diagonal())
+        {
+            connect_directions.push_back(NORTH_EAST);
+            connect_directions.push_back(SOUTH_EAST);
+        }
+        for (Direction d : connect_directions)
         {
             // Find sufficiently large gaps
             Bitboard b = pos.board_bb() & ~pos.pieces(Them);
index 38b253e..f74bdef 100644 (file)
@@ -459,6 +459,9 @@ Variant* VariantParser<DoCheck>::parse(Variant* v) {
     parse_attribute("flagMove", v->flagMove);
     parse_attribute("checkCounting", v->checkCounting);
     parse_attribute("connectN", v->connectN);
+    parse_attribute("connectHorizontal", v->connectHorizontal);
+    parse_attribute("connectVertical", v->connectVertical);
+    parse_attribute("connectDiagonal", v->connectDiagonal);
     parse_attribute("materialCounting", v->materialCounting);
     parse_attribute("countingRule", v->countingRule);
 
index 6084c4d..1d88f53 100644 (file)
@@ -2716,7 +2716,22 @@ bool Position::is_immediate_game_end(Value& result, int ply) const {
   if (connect_n() > 0)
   {
       Bitboard b;
-      for (Direction d : {NORTH, NORTH_EAST, EAST, SOUTH_EAST})
+      std::vector<Direction> connect_directions;
+
+      if (connect_horizontal())
+      {
+          connect_directions.push_back(EAST);
+      }
+      if (connect_vertical())
+      {
+          connect_directions.push_back(NORTH);
+      }
+      if (connect_diagonal())
+      {
+          connect_directions.push_back(NORTH_EAST);
+          connect_directions.push_back(SOUTH_EAST);
+      }
+      for (Direction d : connect_directions)
       {
           b = pieces(~sideToMove);
           for (int i = 1; i < connect_n() && b; i++)
index 381f6fd..f0a5073 100644 (file)
@@ -203,6 +203,10 @@ public:
   bool flag_reached(Color c) const;
   bool check_counting() const;
   int connect_n() const;
+  bool connect_horizontal() const;
+  bool connect_vertical() const;
+  bool connect_diagonal() const;
+
   CheckCount checks_remaining(Color c) const;
   MaterialCounting material_counting() const;
   CountingRule counting_rule() const;
@@ -948,6 +952,20 @@ inline int Position::connect_n() const {
   return var->connectN;
 }
 
+inline bool Position::connect_horizontal() const {
+  assert(var != nullptr);
+  return var->connectHorizontal;
+}
+inline bool Position::connect_vertical() const {
+  assert(var != nullptr);
+  return var->connectVertical;
+}
+inline bool Position::connect_diagonal() const {
+  assert(var != nullptr);
+  return var->connectDiagonal;
+}
+
+
 inline CheckCount Position::checks_remaining(Color c) const {
   return st->checksRemaining[c];
 }
index 97ceaff..c2917fe 100644 (file)
@@ -38,7 +38,7 @@ enum WDLScore {
 // Possible states after a probing operation
 enum ProbeState {
     FAIL              =  0, // Probe failed (missing file table)
-    OK                =  1, // Probe succesful
+    OK                =  1, // Probe successful
     CHANGE_STM        = -1, // DTZ should check the other side
     ZEROING_BEST_MOVE =  2  // Best move zeroes DTZ (capture or pawn move)
 };
index b342c73..bc4862d 100644 (file)
@@ -148,6 +148,9 @@ struct Variant {
   bool flagMove = false;
   bool checkCounting = false;
   int connectN = 0;
+  bool connectHorizontal = true;
+  bool connectVertical = true;
+  bool connectDiagonal = true;
   MaterialCounting materialCounting = NO_MATERIAL_COUNTING;
   CountingRule countingRule = NO_COUNTING;
 
index b581fcc..ddb7fc2 100644 (file)
 # flagMove: the other side gets one more move after one reaches the flag zone [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)
+# connectVertical: connectN looks at Vertical rows [bool] (default: true)
+# connectHorizontal: connectN looks at Horizontal rows [bool] (default: true)
+# connectDiagonal: connectN looks at Diagonal rows [bool] (default: true)
 # materialCounting: enable material counting rules [MaterialCounting] (default: none)
 # countingRule: enable counting rules [CountingRule] (default: none)
 
@@ -1304,6 +1307,8 @@ flagRegionWhite = a5 b5 c5 d5 e5 a4 e4
 flagRegionBlack = a1 b1 c1 d1 e1 a2 e2
 flagPieceCount = 7
 flagPieceBlockedWin = true
+nFoldRule = 0
+nMoveRule = 0
 
 #https://www.chessvariants.com/large.dir/xhess.html
 [xhess:chess]
@@ -1389,7 +1394,7 @@ startFen = KNR2rnk w
 [tuktuk]
 maxRank = 6
 maxFile = f
-customPiece1 = w:mfbR
+customPiece1 = w:mvR
 startFen = wwwwww/6/6/6/6/WWWWWW w
 stalemateValue = loss
 nFoldRule=0
@@ -1435,3 +1440,78 @@ maxFile = e
 customPiece1 = w:mW
 startFen = wWwWw/WwWwW/wW1Ww/WwWwW/wWwWw w
 stalemateValue = loss
+nMoveRule = 0
+
+[picaria:tictactoe]
+#Known under multiple names but using the name from Wikipedia.
+#https://ludii.games/details.php?keyword=Picaria https://en.wikipedia.org/wiki/Picaria
+#https://ludii.games/details.php?keyword=Les%20Pendus
+#https://ludii.games/details.php?keyword=Wure%20Dune
+#https://ludii.games/details.php?keyword=Djara-Badakh
+#https://ludii.games/details.php?keyword=Tuk%20Tak
+customPiece1 = p:mKmNmAmD
+#moves anywhere on the board, KNAD is an list of all possible moves on a 3x3
+startFen = 3/3/3[PPPppp] w - - 0 1
+mustDrop = true
+nMoveRule = 0
+nFoldRule = 0
+
+[nineholes:picaria]
+#https://ludii.games/details.php?keyword=Nine%20Holes https://en.wikipedia.org/wiki/Nine_Holes
+#https://ludii.games/details.php?keyword=San-Noku-Narabe
+#https://ludii.games/details.php?keyword=Driesticken
+#https://ludii.games/details.php?keyword=Akidada
+#https://ludii.games/details.php?keyword=Dris%20at-Talata
+connectDiagonal = false
+
+[asimplegame]
+#https://ludii.games/details.php?keyword=A%20Simple%20Game
+maxRank = 4
+maxFile = d
+customPiece1 = p:mW
+connectN = 3
+startFen = pPpP/4/4/PpPp w - - 0 1
+nMoveRule = 0
+#according to Jan's own Zillions file, any repetition is a draw
+nFoldRule = 2
+
+[alapo:chess]
+#https://www.chessvariants.org/small.dir/alapo.html
+#Reaching the opponent's back row such that the piece isn't immediately
+#captured is a win. Let's promote to a victory piece (Amazon), then, moving
+#that piece to anywhere not on the back row is a victory. There's nothing about
+#the Amazon in the rules, just a powerful piece.
+pieceToCharTable = ..BRQ........AFW.....K..brq........afw.....k
+maxRank = 6
+maxFile = f
+wazir = w
+fers = f
+amazon = a
+king = -
+commoner = k
+startFen = rbqqbr/wfkkfw/6/6/WFKKFW/RBQQBR
+promotionRegionWhite = *6
+promotionRegionBlack = *1
+promotedPieceType = w:a r:a f:a b:a k:a q:a
+mandatoryPiecePromotion = true
+flagPiece = a
+flagRegionWhite = *5 *4 *3 *2 *1
+flagRegionBlack = *6 *5 *4 *3 *2
+stalemateValue = loss
+nMoveRule = 0
+nFoldRule = 0
+
+[rooksquare:chess]
+#https://www.chessvariants.com/diffobjective.dir/rooksquare.html
+flagRegionWhite = a8 h8
+flagRegionBlack = a1 h1
+
+[allqueenschess]
+#https://boardgamegeek.com/boardgame/34948/all-queens-chess
+maxRank = 5
+maxFile = e
+startFen = qQqQq/5/Q3q/5/QqQqQ
+customPiece1 = q:mQ
+connectN = 4
+nMoveRule = 0
+nFoldRule = 0