Simplify CheckDrops()
authorH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 11 Apr 2018 07:25:00 +0000 (09:25 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Thu, 12 Apr 2018 07:14:22 +0000 (09:14 +0200)
CheckDrops() tested half-way the iteration whether it should also try
dropping the unpromoted piece, based on the assumption that we must do
the Pawn iteration for dropping +P, even if dropping P is forbidden.
But in games where +P can be dropped, dropping P (in a place where it
checks) can never be forbidden!

dropper.c

index 6a4ad7e..b4d10fa 100644 (file)
--- a/dropper.c
+++ b/dropper.c
@@ -946,8 +946,8 @@ CheckDrops (int stm, int king)
 {
     int i, lowest = 0;
     if(perpLoses) lowest = !!(pawnCount[sqr2file[king]] & maxBulk[stm]); // in Shogi no Pawn if file already crowded with those
-    else lowest = (stm == WHITE ? king < 2*22 : king >= 6*22);           // in zh no Pawn from back rank
-    for(i=maxDrop; i>=0; i--) {
+    else lowest = (stm == WHITE ? king < 2*22 : king >= 6*22); // in zh no Pawn from back rank
+    for(i=maxDrop; i>=lowest; i--) { // note: in games with promoDrops lowest=0 as Pawns have no bulk there
        int piece = stm + i, from = handSlot[piece^COLOR];
        if((signed char)board[from] < -1) { // piece type is in hand
            int step, dir;
@@ -961,7 +961,6 @@ CheckDrops (int stm, int king)
                    }
                }
            }
-           if(i < lowest) break; // suppresses back-rank Pawn drops in zh
            dir = 2*firstDir[piece-WHITE];
            while((step = steps[dir++])) {
                int to = king, range = steps[dir++];