Fix quiet check move generation
authorFabian Fichter <ianfab@users.noreply.github.com>
Mon, 4 Apr 2022 17:37:18 +0000 (19:37 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Mon, 4 Apr 2022 17:37:18 +0000 (19:37 +0200)
for mandatory piece promotions.

src/movegen.cpp

index ed17247..57d647d 100644 (file)
@@ -263,15 +263,6 @@ namespace {
         Bitboard b2 = promPt && (!pos.promotion_limit(promPt) || pos.promotion_limit(promPt) > pos.count(Us, promPt)) ? b1 : Bitboard(0);
         Bitboard b3 = pos.piece_demotion() && pos.is_promoted(from) ? b1 : Bitboard(0);
 
-        if (Checks)
-        {
-            b1 &= pos.check_squares(Pt);
-            if (b2)
-                b2 &= pos.check_squares(pos.promoted_piece_type(Pt));
-            if (b3)
-                b3 &= pos.check_squares(type_of(pos.unpromoted_piece_on(from)));
-        }
-
         // Restrict target squares considering promotion zone
         if (b2 | b3)
         {
@@ -292,6 +283,15 @@ namespace {
             }
         }
 
+        if (Checks)
+        {
+            b1 &= pos.check_squares(Pt);
+            if (b2)
+                b2 &= pos.check_squares(pos.promoted_piece_type(Pt));
+            if (b3)
+                b3 &= pos.check_squares(type_of(pos.unpromoted_piece_on(from)));
+        }
+
         while (b1)
             moveList = make_move_and_gating<NORMAL>(pos, moveList, Us, from, pop_lsb(b1));