Support dobutsu shogi
authorFabian Fichter <ianfab@users.noreply.github.com>
Sat, 10 Nov 2018 16:49:46 +0000 (17:49 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sat, 10 Nov 2018 16:52:45 +0000 (17:52 +0100)
Readme.md
src/movegen.cpp
src/position.h
src/variant.cpp
src/variant.h

index b296e47..6e5241d 100644 (file)
--- a/Readme.md
+++ b/Readme.md
@@ -10,7 +10,7 @@ Besides chess, the currently supported variants are:
 **Regional and historical variants**
 - [Shatranj](https://en.wikipedia.org/wiki/Shatranj)
 - [Makruk](https://en.wikipedia.org/wiki/Makruk), [ASEAN](http://hgm.nubati.net/rules/ASEAN.html), Ai-Wok, [Sittuyin](https://en.wikipedia.org/wiki/Sittuyin)
-- [Minishogi](https://en.wikipedia.org/wiki/Minishogi), [EuroShogi](https://en.wikipedia.org/wiki/EuroShogi), [Judkins shogi](https://en.wikipedia.org/wiki/Judkins_shogi)
+- [Minishogi](https://en.wikipedia.org/wiki/Minishogi), [EuroShogi](https://en.wikipedia.org/wiki/EuroShogi), [Judkins shogi](https://en.wikipedia.org/wiki/Judkins_shogi), [Dobutsu shogi](https://en.wikipedia.org/wiki/Dōbutsu_shōgi)
 
 **Modern variants**
 - [Chess960](https://en.wikipedia.org/wiki/Chess960), [Placement/Pre-Chess](https://www.chessvariants.com/link/placement-chess)
index 6996f6d..910717e 100644 (file)
@@ -92,7 +92,7 @@ namespace {
             if (!pos.first_rank_drops())
                 b &= ~rank_bb(relative_rank(Us, RANK_1, pos.max_rank()));
         }
-        if (pt == SHOGI_PAWN)
+        if (pt == SHOGI_PAWN && !pos.shogi_doubled_pawn())
             for (File f = FILE_A; f <= pos.max_file(); ++f)
                 if (file_bb(f) & pos.pieces(Us, pt))
                     b &= ~file_bb(f);
index d362e00..fb82d93 100644 (file)
@@ -118,6 +118,7 @@ public:
   Bitboard drop_region(Color c) const;
   bool sittuyin_rook_drop() const;
   bool drop_opposite_colored_bishop() const;
+  bool shogi_doubled_pawn() const;
   bool immobility_illegal() const;
   // winning conditions
   Value stalemate_value(int ply = 0) const;
@@ -410,6 +411,11 @@ inline bool Position::drop_opposite_colored_bishop() const {
   return var->dropOppositeColoredBishop;
 }
 
+inline bool Position::shogi_doubled_pawn() const {
+  assert(var != nullptr);
+  return var->shogiDoubledPawn;
+}
+
 inline bool Position::immobility_illegal() const {
   assert(var != nullptr);
   return var->immobilityIllegal;
index d5f9ed1..dc819f5 100644 (file)
@@ -263,10 +263,31 @@ VariantMap variants; // Global object
         v->promotedPieceType[SILVER]     = GOLD;
         v->promotedPieceType[BISHOP]     = HORSE;
         v->promotedPieceType[ROOK]       = DRAGON;
+        v->shogiDoubledPawn = false;
         v->immobilityIllegal = true;
         v->shogiPawnDropMateIllegal = true;
         return v;
     }
+    Variant* dobutsu_variant() {
+        Variant* v = minishogi_variant();
+        v->maxRank = RANK_4;
+        v->maxFile = FILE_C;
+        v->reset_pieces();
+        v->add_piece(SHOGI_PAWN, 'c');
+        v->add_piece(GOLD, 'h');
+        v->add_piece(FERS, 'e');
+        v->add_piece(WAZIR, 'g');
+        v->add_piece(KING, 'l');
+        v->startFen = "gle/1c1/1C1/GLE[-] w 0 1";
+        v->promotionRank = RANK_4;
+        v->immobilityIllegal = false;
+        v->shogiPawnDropMateIllegal = false;
+        v->flagPiece = KING;
+        v->whiteFlag = Rank4BB;
+        v->blackFlag = Rank1BB;
+        v->shogiDoubledPawn = true;
+        return v;
+    }
     Variant* judkinsshogi_variant() {
         Variant* v = minishogi_variant();
         v->maxRank = RANK_6;
@@ -499,6 +520,7 @@ void VariantMap::init() {
     add("euroshogi", euroshogi_variant());
     add("judkinshogi", judkinsshogi_variant());
     add("minishogi", minishogi_variant());
+    add("dobutsu", dobutsu_variant());
     add("losalamos", losalamos_variant());
     add("almost", almost_variant());
     add("chigorin", chigorin_variant());
index dd29916..fc9314c 100644 (file)
@@ -63,6 +63,7 @@ struct Variant {
   Bitboard blackDropRegion = AllSquares;
   bool sittuyinRookDrop = false;
   bool dropOppositeColoredBishop = false;
+  bool shogiDoubledPawn = false;
   bool immobilityIllegal = false;
   // game end
   Value stalemateValue = VALUE_DRAW;