Support seirawan-crazyhouse
authorFabian Fichter <ianfab@users.noreply.github.com>
Wed, 14 Aug 2019 20:04:36 +0000 (22:04 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Fri, 23 Aug 2019 21:12:16 +0000 (23:12 +0200)
src/movegen.cpp
src/position.cpp
src/variant.cpp

index 17ec978..e4c7487 100644 (file)
@@ -31,11 +31,11 @@ namespace {
     *moveList++ = make<T>(from, to);
 
     // Gating moves
-    if (pos.gating() && (pos.gates(us) & square_bb(from)))
+    if (pos.gating() && (pos.gates(us) & from))
         for (PieceType pt_gating = PAWN; pt_gating <= KING; ++pt_gating)
             if (pos.count_in_hand(us, pt_gating) && (pos.drop_region(us, pt_gating) & from))
                 *moveList++ = make_gating<T>(from, to, pt_gating, from);
-    if (pos.gating() && T == CASTLING && (pos.gates(us) & square_bb(to)))
+    if (pos.gating() && T == CASTLING && (pos.gates(us) & to))
         for (PieceType pt_gating = PAWN; pt_gating <= KING; ++pt_gating)
             if (pos.count_in_hand(us, pt_gating) && (pos.drop_region(us, pt_gating) & to))
                 *moveList++ = make_gating<T>(from, to, pt_gating, to);
index b2aee5a..4aa12ed 100644 (file)
@@ -380,7 +380,7 @@ Position& Position::set(const Variant* v, const string& fenStr, bool isChess960,
                   st->gatesBB[c] |= count<KING>(c) ? square<KING>(c) : make_square(FILE_E, relative_rank(c, castling_rank(), max_rank()));
               // Do not set castling rights for gates unless there are no pieces in hand,
               // which means that the file is referring to a chess960 castling right.
-              else if (count_in_hand(c, ALL_PIECES))
+              else if (count_in_hand(c, ALL_PIECES) || captures_to_hand())
                   continue;
           }
 
@@ -390,7 +390,7 @@ Position& Position::set(const Variant* v, const string& fenStr, bool isChess960,
       // Set castling rights for 960 gating variants
       if (gating())
           for (Color c : {WHITE, BLACK})
-              if ((gates(c) & pieces(KING)) && !castling_rights(c) && count_in_hand(c, ALL_PIECES))
+              if ((gates(c) & pieces(KING)) && !castling_rights(c) && (count_in_hand(c, ALL_PIECES) || captures_to_hand()))
               {
                   Bitboard castling_rooks = gates(c) & pieces(ROOK);
                   while (castling_rooks)
@@ -637,9 +637,9 @@ const string Position::fen() const {
   if (can_castle(WHITE_OOO))
       ss << (chess960 ? char('A' + file_of(castling_rook_square(WHITE_OOO))) : 'Q');
 
-  if (gating() && gates(WHITE))
+  if (gating() && gates(WHITE) && (count_in_hand(WHITE, ALL_PIECES) || captures_to_hand()))
       for (File f = FILE_A; f <= max_file(); ++f)
-          if ((gates(WHITE) & file_bb(f)) && count_in_hand(WHITE, ALL_PIECES))
+          if (gates(WHITE) & file_bb(f))
               ss << char('A' + f);
 
   if (can_castle(BLACK_OO))
@@ -648,9 +648,9 @@ const string Position::fen() const {
   if (can_castle(BLACK_OOO))
       ss << (chess960 ? char('a' + file_of(castling_rook_square(BLACK_OOO))) : 'q');
 
-  if (gating() && gates(BLACK))
+  if (gating() && gates(BLACK) && (count_in_hand(BLACK, ALL_PIECES) || captures_to_hand()))
       for (File f = FILE_A; f <= max_file(); ++f)
-          if ((gates(BLACK) & file_bb(f)) && count_in_hand(BLACK, ALL_PIECES))
+          if (gates(BLACK) & file_bb(f))
               ss << char('a' + f);
 
   if (!can_castle(ANY_CASTLING) && !(gating() && (gates(WHITE) | gates(BLACK))))
index 86aa833..2ff7823 100644 (file)
@@ -255,11 +255,15 @@ VariantMap variants; // Global object
         v->add_piece(CHANCELLOR, 'e');
         v->startFen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR[HEhe] w KQBCDFGkqbcdfg - 0 1";
         v->gating = true;
-        v->whiteDropRegion = Rank1BB;
-        v->blackDropRegion = Rank8BB;
         v->promotionPieceTypes = {ARCHBISHOP, CHANCELLOR, QUEEN, ROOK, BISHOP, KNIGHT};
         return v;
     }
+    Variant* shouse_variant() {
+        Variant* v = seirawan_variant();
+        v->pieceDrops = true;
+        v->capturesToHand = true;
+        return v;
+    }
     Variant* minishogi_variant_base() {
         Variant* v = fairy_variant_base();
         v->variantTemplate = "shogi";
@@ -691,6 +695,7 @@ void VariantMap::init() {
     add("placement", placement_variant());
     add("sittuyin", sittuyin_variant());
     add("seirawan", seirawan_variant());
+    add("shouse", shouse_variant());
     add("minishogi", minishogi_variant());
     add("mini", minishogi_variant());
     add("kyotoshogi", kyotoshogi_variant());