Claim win against illegal move if opponent is computer
authorH.G. Muller <h.g.muller@hccnet.nl>
Fri, 18 Jan 2013 14:59:18 +0000 (15:59 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Fri, 18 Jan 2013 14:59:18 +0000 (15:59 +0100)
Otherwise the game would hang in Two Machines mode, which is very undesirable
if the opponent is a connection adapter to a server.

hachu.c

diff --git a/hachu.c b/hachu.c
index ad1bd20..59fbacf 100644 (file)
--- a/hachu.c
+++ b/hachu.c
@@ -94,7 +94,7 @@ typedef struct {
 char *array, *reason;\r
 int bWidth, bHeight, bsize, zone, currentVariant;\r
 int stm, xstm, hashKeyH, hashKeyL, framePtr, msp, nonCapts, rootEval, retMSP, retFirst, retDep, pvPtr, level, cnt50, chuFlag=1, tenFlag, mobilityScore;\r
-int nodes, startTime, tlim1, tlim2, repCnt;\r
+int nodes, startTime, tlim1, tlim2, repCnt, comp;\r
 Move retMove, moveStack[10000], path[100], repStack[300], pv[1000], repeatMove[300];\r
 \r
 #define X 36 /* slider              */\r
@@ -2161,7 +2161,10 @@ printf("var %d\n",i);
         if(!strcmp(command, "memory"))  { SetMemorySize(atoi(inBuf+7)); continue; }\r
         if(!strcmp(command, "ping"))    { printf("pong%s", inBuf+4); continue; }\r
     //  if(!strcmp(command, ""))        { sscanf(inBuf, " %d", &); continue; }\r
-        if(!strcmp(command, "new"))     { engineSide = BLACK; Init(V_CHESS); stm = Setup2(DEFAULT_FEN); maxDepth = MAXPLY; randomize = OFF; continue; }\r
+        if(!strcmp(command, "new"))     {\r
+          engineSide = BLACK; Init(V_CHESS); stm = Setup2(DEFAULT_FEN); maxDepth = MAXPLY; randomize = OFF; comp = 0;\r
+          continue;\r
+        }\r
         if(!strcmp(command, "setboard")){ engineSide = NONE;  stm = Setup2(inBuf+9); continue; }\r
         if(!strcmp(command, "easy"))    { ponder = OFF; continue; }\r
         if(!strcmp(command, "hard"))    { ponder = ON;  continue; }\r
@@ -2183,7 +2186,7 @@ printf("var %d\n",i);
         if(!strcmp(command, "l"))       { pplist(); continue; }\r
         // ignored commands:\r
         if(!strcmp(command, "xboard"))  { continue; }\r
-        if(!strcmp(command, "computer")){ continue; }\r
+        if(!strcmp(command, "computer")){ comp = 1; continue; }\r
         if(!strcmp(command, "name"))    { continue; }\r
         if(!strcmp(command, "ics"))     { continue; }\r
         if(!strcmp(command, "accepted")){ continue; }\r
@@ -2195,6 +2198,7 @@ printf("var %d\n",i);
           int move = ParseMove(inBuf+9);\r
           if(move == INVALID) {\r
             if(reason) printf("Illegal move {%s}\n", reason); else printf("%s\n", reason="Illegal move");\r
+            if(comp) PrintResult(stm, -INF); // against computer: claim\r
           } else {\r
             stm = MakeMove2(stm, move);\r
             ponderMove = INVALID;\r