X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=92df2bb86824d5480708b69eef1a1e413814b405;hb=240d6d730bdd00e94d70a589e352e8eb4eb9a174;hp=d4549bfb756aefeba157310b2f42e2ed06f2dd08;hpb=e54045072f6e157b46a33104b8094cf9857f875d;p=xboard.git diff --git a/backend.c b/backend.c index d4549bf..92df2bb 100644 --- a/backend.c +++ b/backend.c @@ -2206,8 +2206,8 @@ MatchSoughtLine(char *line) int DrawSeekGraph() { - if(!seekGraphUp) return FALSE; int i; + if(!seekGraphUp) return FALSE; h = BOARD_HEIGHT * (squareSize + lineGap) + lineGap; w = BOARD_WIDTH * (squareSize + lineGap) + lineGap; @@ -6595,8 +6595,9 @@ Count(Board board, int pCnt[], int *nW, int *nB, int *wStale, int *bStale, int * for(p=WhitePawn; p<=EmptySquare; p++) pCnt[p] = 0; for(r=0; r 2) return FALSE; // no trivial draws with more than 1 major + if(myPawns == 2 && nMine == 3) // KPP + return majorDefense || pCnt[BlackFerz-side] + pCnt[BlackAlfil-side] >= 3; + if(myPawns == 1 && nMine == 2) // KP + return majorDefense || pCnt[BlackFerz-side] + pCnt[BlackAlfil-side] + pCnt[BlackPawn-side] >= 1; + if(myPawns == 1 && nMine == 3 && pCnt[WhiteKnight+side]) // KHP + return majorDefense || pCnt[BlackFerz-side] + pCnt[BlackAlfil-side]*2 >= 5; + if(myPawns) return FALSE; + if(pCnt[WhiteRook+side]) + return pCnt[BlackRook-side] || + pCnt[BlackCannon-side] && (pCnt[BlackFerz-side] >= 2 || pCnt[BlackAlfil-side] >= 2) || + pCnt[BlackKnight-side] && pCnt[BlackFerz-side] + pCnt[BlackAlfil-side] > 2 || + pCnt[BlackFerz-side] + pCnt[BlackAlfil-side] >= 4; + if(pCnt[WhiteCannon+side]) { + if(pCnt[WhiteFerz+side] + myPawns == 0) return TRUE; // Cannon needs platform + return majorDefense || pCnt[BlackAlfil-side] >= 2; + } + if(pCnt[WhiteKnight+side]) + return majorDefense || pCnt[BlackFerz-side] >= 2 || pCnt[BlackAlfil-side] + pCnt[BlackPawn-side] >= 1; + return FALSE; +} + +int MatingPotential(int pCnt[], int side, int nMine, int nHis, int stale, int bisColor) { VariantClass v = gameInfo.variant; @@ -6798,12 +6828,14 @@ Adjudicate(ChessProgramState *cps) } /* Then some trivial draws (only adjudicate, cannot be claimed) */ - if(nrW + nrB == 4 && + if(gameInfo.variant == VariantXiangqi ? + SufficientDefence(nr, WhitePawn, nrW, nrB) && SufficientDefence(nr, BlackPawn, nrB, nrW) + : nrW + nrB == 4 && ( nr[WhiteRook] == 1 && nr[BlackRook] == 1 /* KRKR */ || nr[WhiteQueen] && nr[BlackQueen]==1 /* KQKQ */ || nr[WhiteKnight]==2 || nr[BlackKnight]==2 /* KNNK */ || nr[WhiteKnight]+nr[WhiteBishop] == 1 && nr[BlackKnight]+nr[BlackBishop] == 1 /* KBKN, KBKB, KNKN */ - ) ) { + ) ) { if(--moveCount < 0 && appData.trivialDraws && canAdjudicate) { /* if the first 3 moves do not show a tactical win, declare draw */ if(engineOpponent) { @@ -9334,7 +9366,12 @@ GameEnds(result, resultDetails, whosays) gameMode = nextGameMode; ModeHighlight(); endingGame = 0; /* [HGM] crash */ - if(popupRequested) DisplayFatalError(buf, 0, 0); // [HGM] crash: this call GameEnds recursively through ExitEvent! Make it a harmless tail recursion. + if(popupRequested) { // [HGM] crash: this calls GameEnds recursively through ExitEvent! Make it a harmless tail recursion. + if(matchMode == TRUE) DisplayFatalError(buf, 0, 0); else { + matchMode = FALSE; appData.matchGames = matchGame = 0; + DisplayNote(buf); + } + } } /* Assumes program was just initialized (initString sent). @@ -14762,7 +14799,7 @@ ParseFEN(board, blackPlaysFirst, fen) char *fen; { int i, j; - char *p; + char *p, c; int emptycount; ChessSquare piece; @@ -14855,7 +14892,12 @@ ParseFEN(board, blackPlaysFirst, fen) while(*p == ' ') p++; /* Active color */ - switch (*p++) { + c = *p++; + if(appData.colorNickNames) { + if( c == appData.colorNickNames[0] ) c = 'w'; else + if( c == appData.colorNickNames[1] ) c = 'b'; + } + switch (c) { case 'w': *blackPlaysFirst = FALSE; break;