Implement e.p. capture
[hachu.git] / hachu.c
diff --git a/hachu.c b/hachu.c
index ce8ccc4..3367f3c 100644 (file)
--- a/hachu.c
+++ b/hachu.c
@@ -1242,6 +1242,8 @@ MakeMove(Move m, UndoInfo *u)
 \r
   if(p[u->piece].promoFlag & LAST_RANK) cnt50 = 0; // forward piece: move is irreversible\r
   // TODO: put in some test for forward moves of non-backward pieces?\r
+//             int n = board[promoSuppress-1];\r
+//             if( n != EMPTY && (n&TYPE) == xstm && p[n].value == 8 ) NewNonCapt(promoSuppress-1, 16, 0);\r
 \r
   if(p[u->piece].value == FVAL) { // move with Fire Demon\r
     int i, f=~fireFlags[u->piece-2];\r
@@ -1839,15 +1841,18 @@ if(PATH) printf("%d:%2d:%2d msp=%d\n",level,depth,iterDep,msp);
 if(PATH) printf("captures on %d generated, msp=%d, group=%d, threshold=%d\n", nextVictim, msp, group, threshold);\r
              goto extractMove; // in auto-fail phase, only search if they might auto-fail-hi\r
            }\r
+           if(chessFlag && promoSuppress != ABSENT) { // e.p. rights. Create e.p. captures as Lion moves\r
+               int n = board[promoSuppress-1], old = msp; // a-side neighbor of pushed pawn\r
+               if( n != EMPTY && (n&TYPE) == stm && p[n].value == 80 ) NewCapture(promoSuppress-1, SPECIAL + 20 - 4*stm, 0);\r
+               n = board[promoSuppress+1];      // h-side neighbor of pushed pawn\r
+               if( n != EMPTY && (n&TYPE) == stm && p[n].value == 80 ) NewCapture(promoSuppress+1, SPECIAL + 52 - 4*stm, 0);\r
+               if(msp != old) goto extractMove; // one or more e.p. capture were generated\r
+           }\r
 if(PATH) printf("# autofail=%d\n", autoFail);\r
            if(autoFail) { // non-captures cannot auto-fail; flush queued captures first\r
 if(PATH) printf("# autofail end (%d-%d)\n", firstMove, msp);\r
              autoFail = 0; curMove = firstMove - 1; continue; // release stashed moves for search\r
            }\r
-//         if(currentVariant == V_CHESS && promoSuppress != ABSENT) { // e.p.\r
-//             int n = board[promoSuppress-1];\r
-//             if( n != EMPTY && (n&TYPE) == xstm && p[n].value == 8 ) \r
-//         }\r
            phase = 4; // out of victims: all captures generated\r
          case 4: // dubious captures\r
 #if 0\r
@@ -2337,6 +2342,11 @@ ParseMove (char *moveText)
     for(j=0; j<8; j++) if(e + kStep[j] == t) break;\r
     if(j >= 8) return INVALID; // this rejects Lion Dog 1+2 moves!\r
     t2 = SPECIAL + 8*i + j;\r
+  } else if(chessFlag && board[f] != EMPTY && p[board[f]].value == 80 && board[t] == EMPTY) { // Pawn to empty, could be e.p.\r
+      if(t == f + BW + 1) t2 = SPECIAL + 16; else\r
+      if(t == f + BW - 1) t2 = SPECIAL + 48; else\r
+      if(t == f - BW + 1) t2 = SPECIAL + 20; else\r
+      if(t == f - BW - 1) t2 = SPECIAL + 52; // fake double-move\r
   }\r
   ret = f<<SQLEN | t2;\r
   if(*moveText != '\n' && *moveText != '=') ret |= PROMOTE;\r