updated patchlevel to "i"
[xboard.git] / backend.c
index 9c7e1c4..9c49e05 100644 (file)
--- 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)\r
                                        hisPerpetual = 0; // the opponent did not always check\r
                                }\r
+                               if(appData.debugMode) fprintf(debugFP, "XQ perpetual test, our=%d, his=%d\n",\r
+                                                                       ourPerpetual, hisPerpetual);\r
                                if(ourPerpetual && !hisPerpetual) { // we are actively checking him: forfeit\r
                                    GameEnds( WhiteOnMove(forwardMostMove) ? WhiteWins : BlackWins, \r
                                           "Xboard adjudication: perpetual checking", GE_XBOARD );\r
@@ -6003,8 +6005,19 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h
                                }\r
                                if(hisPerpetual && !ourPerpetual)   // he is checking us, but did not repeat yet\r
                                    break; // (or we would have caught him before). Abort repetition-checking loop.\r
-                               // if neither of us is checking all the time, or both are, it is draw\r
-                               // (illegal-chase forfeits not implemented yet!)\r
+                               // Now check for perpetual chases\r
+                               if(!ourPerpetual && !hisPerpetual) { // no perpetual check, test for chase\r
+                                   hisPerpetual = PerpetualChase(k, forwardMostMove);\r
+                                   ourPerpetual = PerpetualChase(k+1, forwardMostMove);\r
+                                   if(ourPerpetual && !hisPerpetual) { // we are actively checking him: forfeit\r
+                                       GameEnds( WhiteOnMove(forwardMostMove) ? WhiteWins : BlackWins, \r
+                                                     "Xboard adjudication: perpetual chasing", GE_XBOARD );\r
+                                       return;\r
+                                   }\r
+                                   if(hisPerpetual && !ourPerpetual)   // he is chasing us, but did not repeat yet\r
+                                       break; // Abort repetition-checking loop.\r
+                               }\r
+                               // if neither of us is checking or chasing all the time, or both are, it is draw\r
                             }\r
                              GameEnds( GameIsDrawn, "Xboard adjudication: repetition draw", GE_XBOARD );\r
                              return;\r