X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=moves.c;h=c11a8f3f6bbabc08b6e52bb020ad5ac95d77e4fe;hb=cf8ee83ef1cee354cad4503b242f724abac1fe68;hp=56b4cb1eb0f633c865397c6535694a2243cd644f;hpb=5044bd45730eb785494c8a3ffc29cf05ead43068;p=xboard.git diff --git a/moves.c b/moves.c index 56b4cb1..c11a8f3 100644 --- a/moves.c +++ b/moves.c @@ -727,6 +727,7 @@ void GenLegalCallback(board, flags, kind, rf, ff, rt, ft, closure) typedef struct { int rf, ff, rt, ft; ChessMove kind; + int captures; // [HGM] losers } LegalityTestClosure; @@ -1026,6 +1027,8 @@ void LegalityTestCallback(board, flags, kind, rf, ff, rt, ft, closure) // if (appData.debugMode) { // fprintf(debugFP, "Legality test: %c%c%c%c\n", ff+AAA, rf+ONE, ft+AAA, rt+ONE); // } + if(board[rt][ft] != EmptySquare || kind==WhiteCapturesEnPassant || kind==BlackCapturesEnPassant) + cl->captures++; // [HGM] losers: count legal captures if (rf == cl->rf && ff == cl->ff && rt == cl->rt && ft == cl->ft) cl->kind = kind; } @@ -1055,7 +1058,11 @@ ChessMove LegalityTest(board, flags, epfile, castlingRights, rf, ff, rt, ft, pro cl.rt = rt; cl.ft = ft; cl.kind = IllegalMove; + cl.captures = 0; // [HGM] losers: prepare to count legal captures. GenLegal(board, flags, epfile, castlingRights, LegalityTestCallback, (VOIDSTAR) &cl); + if((flags & F_MANDATORY_CAPTURE) && cl.captures && board[rt][ft] == EmptySquare + && cl.kind != WhiteCapturesEnPassant && cl.kind != BlackCapturesEnPassant) + return(IllegalMove); // [HGM] losers: if there are legal captures, non-capts are illegal if(gameInfo.variant == VariantShogi) { /* [HGM] Shogi promotions. '=' means defer */