Adjudicate perpetual checks as loss also in Shogi
authorH.G. Muller <h.g.muller@hccnet.nl>
Fri, 25 Jan 2013 09:05:44 +0000 (10:05 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Fri, 25 Jan 2013 14:52:55 +0000 (15:52 +0100)
The Xiangqi code for recognizing perpetual checks is now also activated for
Shogi, but in this case we bail out before checking for perpetual chases.
The mini-Shogi case is then recognized as a win for gote.

backend.c

index aafb11f..67e2d1b 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -7859,7 +7859,7 @@ Adjudicate (ChessProgramState *cps)
                              /* adjudicate after user-specified nr of repeats */
                             int result = GameIsDrawn;
                             char *details = "XBoard adjudication: repetition draw";
-                            if(gameInfo.variant == VariantXiangqi && appData.testLegality) {
+                            if((gameInfo.variant == VariantXiangqi || gameInfo.variant == VariantShogi) && appData.testLegality) {
                                // [HGM] xiangqi: check for forbidden perpetuals
                                int m, ourPerpetual = 1, hisPerpetual = 1;
                                for(m=forwardMostMove; m>k; m-=2) {
@@ -7877,6 +7877,12 @@ Adjudicate (ChessProgramState *cps)
                                if(hisPerpetual && !ourPerpetual) { // he is checking us, but did not repeat yet
                                    break; // (or we would have caught him before). Abort repetition-checking loop.
                                } else
+                               if(gameInfo.variant == VariantShogi) { // in Shogi other repetitions are draws
+                                   if(BOARD_HEIGHT == 5 && BOARD_RGHT - BOARD_LEFT == 5) { // but in mini-Shogi gote wins!
+                                       result = BlackWins;
+                                       details = "Xboard adjudication: repetition";
+                                   }
+                               } else // it must be XQ
                                // Now check for perpetual chases
                                if(!ourPerpetual && !hisPerpetual) { // no perpetual check, test for chase
                                    hisPerpetual = PerpetualChase(k, forwardMostMove);