X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=4db36c38d662c00d5c6232f9e144f62fa4a13523;hb=35958a4e08bb03564ef2c98672a146e9c23365c7;hp=f5f9f99c5cbd4fa2d3275b5bb4fa1a27ffef0055;hpb=401af411c08c05ad4e6d4c2653cb2df971ab0e21;p=xboard.git diff --git a/backend.c b/backend.c index f5f9f99..4db36c3 100644 --- a/backend.c +++ b/backend.c @@ -6640,8 +6640,10 @@ Adjudicate(ChessProgramState *cps) case BlackRook: NrBR++; break; case WhiteQueen: + case WhiteCannon: NrWQ++; break; case BlackQueen: + case BlackCannon: NrBQ++; break; case EmptySquare: break; @@ -6763,7 +6765,10 @@ Adjudicate(ChessProgramState *cps) if( NrPieces == 2 || gameInfo.variant != VariantXiangqi && gameInfo.variant != VariantShatranj && // [HGM] baring will remain possible (NrPieces == 3 && NrWN+NrBN+NrWB+NrBB == 1 || - NrPieces == NrBB+NrWB+2 && bishopsColor != 3)) // [HGM] all Bishops (Ferz!) same color + NrPieces == NrBB+NrWB+2 && bishopsColor != 3) // [HGM] all Bishops (Ferz!) same color + || gameInfo.variant == VariantXiangqi && + (NrPieces == 3 && (NrWQ==1 && NrWB==0 && NrBB<2 || NrBQ==1 && NrBB==0 && NrWB<2) || + NrPieces == 4 && NrWQ==1 && NrBQ==1 && NrWB==0 && NrBB==0)) { /* KBK, KNK, KK of KBKB with like Bishops */ /* always flag draws, for judging claims */ @@ -6897,6 +6902,17 @@ Adjudicate(ChessProgramState *cps) if( count == backwardMostMove ) count -= initialRulePlies; count = forwardMostMove - count; + if(gameInfo.variant == VariantXiangqi && ( count >= 100 || count >= 2*appData.ruleMoves ) ) { + // adjust reversible move counter for checks in Xiangqi + int i = forwardMostMove - count, inCheck = 0, lastCheck; + if(i < backwardMostMove) i = backwardMostMove; + while(i <= forwardMostMove) { + lastCheck = inCheck; // check evasion does not count + inCheck = (MateTest(boards[i], PosFlags(i)) == MT_CHECK); + if(inCheck || lastCheck) count--; // check does not count + i++; + } + } if( count >= 100) boards[forwardMostMove][EP_STATUS] = EP_RULE_DRAW; /* this is used to judge if draw claims are legal */ @@ -8581,7 +8597,7 @@ MakeMove(fromX, fromY, toX, toY, promoChar) if( (boards[forwardMostMove][fromY][fromX] == WhitePawn || boards[forwardMostMove][fromY][fromX] == BlackPawn ) && boards[forwardMostMove][toY][toX] == EmptySquare - && fromX != toX ) + && fromX != toX && fromY != toY) fprintf(serverMoves, ":%c%c:%c%c", AAA+fromX, ONE+fromY, AAA+toX, ONE+fromY); // promotion suffix if(promoChar != NULLCHAR) @@ -10172,6 +10188,7 @@ LoadGame(f, gameNumber, title, useList) /* [HGM] PGNvariant: automatically switch to variant given in PGN tag */ if(gameInfo.variant != oldVariant) { startedFromPositionFile = FALSE; /* [HGM] loadPos: variant switch likely makes position invalid */ + ResetFrontEnd(); // [HGM] might need other bitmaps. Cannot use Reset() because it clears gameInfo :-( InitPosition(TRUE); oldVariant = gameInfo.variant; if (appData.debugMode)