X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=9c49e05068782aac0e3d9b58390148ebea5b2d2d;hb=82404dad2e42e00c825fd0d883c332ab709684c0;hp=9c7e1c4ab354cd1458598f935165b37f0d006046;hpb=91d8e5853ca580769cc130aa6ea004869118d171;p=xboard.git diff --git a/backend.c b/backend.c index 9c7e1c4..9c49e05 100644 --- a/backend.c +++ b/backend.c @@ -5996,6 +5996,8 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h EP_NONE, castlingRights[m-1]) != MT_CHECK) hisPerpetual = 0; // the opponent did not always check } + if(appData.debugMode) fprintf(debugFP, "XQ perpetual test, our=%d, his=%d\n", + ourPerpetual, hisPerpetual); if(ourPerpetual && !hisPerpetual) { // we are actively checking him: forfeit GameEnds( WhiteOnMove(forwardMostMove) ? WhiteWins : BlackWins, "Xboard adjudication: perpetual checking", GE_XBOARD ); @@ -6003,8 +6005,19 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h } if(hisPerpetual && !ourPerpetual) // he is checking us, but did not repeat yet break; // (or we would have caught him before). Abort repetition-checking loop. - // if neither of us is checking all the time, or both are, it is draw - // (illegal-chase forfeits not implemented yet!) + // Now check for perpetual chases + if(!ourPerpetual && !hisPerpetual) { // no perpetual check, test for chase + hisPerpetual = PerpetualChase(k, forwardMostMove); + ourPerpetual = PerpetualChase(k+1, forwardMostMove); + if(ourPerpetual && !hisPerpetual) { // we are actively checking him: forfeit + GameEnds( WhiteOnMove(forwardMostMove) ? WhiteWins : BlackWins, + "Xboard adjudication: perpetual chasing", GE_XBOARD ); + return; + } + if(hisPerpetual && !ourPerpetual) // he is chasing us, but did not repeat yet + break; // Abort repetition-checking loop. + } + // if neither of us is checking or chasing all the time, or both are, it is draw } GameEnds( GameIsDrawn, "Xboard adjudication: repetition draw", GE_XBOARD ); return;