Only consider kingless positions as in-check in Atomic
authorH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 27 Nov 2016 22:35:24 +0000 (23:35 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 13 Jan 2017 15:39:24 +0000 (16:39 +0100)
The check test returned 1000 (as special version of TRUE) when there
was no King that could be exposed to capture, under the assumption that
this would mean it had been exploded by the preceding move. But this was
counter-productive in variants without King (such as Horde). So now it
is only done in Atomic Chess, and all other variants return FALSE if there
is nothing on the board that could be checked.

moves.c

diff --git a/moves.c b/moves.c
index 876564c..30f94b5 100644 (file)
--- a/moves.c
+++ b/moves.c
@@ -1768,10 +1768,10 @@ CheckTest (Board board, int flags, int rf, int ff, int rt, int ft, int enPassant
     /* For compatibility with ICS wild 9, we scan the board in the
        order a1, a2, a3, ... b1, b2, ..., h8 to find the first king,
        and we test only whether that one is in check. */
+    cl.check = 0;
     for (cl.fking = BOARD_LEFT+0; cl.fking < BOARD_RGHT; cl.fking++)
        for (cl.rking = 0; cl.rking < BOARD_HEIGHT; cl.rking++) {
           if (board[cl.rking][cl.fking] == king) {
-             cl.check = 0;
               if(gameInfo.variant == VariantXiangqi) {
                   /* [HGM] In Xiangqi opposing Kings means check as well */
                   int i, dir;
@@ -1806,7 +1806,7 @@ CheckTest (Board board, int flags, int rf, int ff, int rt, int ft, int enPassant
        board[EP_STATUS] = ep;
     }
 
-    return cl.fking < BOARD_RGHT ? cl.check : 1000; // [HGM] atomic: return 1000 if we have no king
+    return cl.fking < BOARD_RGHT ? cl.check : (gameInfo.variant == VariantAtomic)*1000; // [HGM] atomic: return 1000 if we have no king
 }
 
 int