From 62077784733af1f94035193b31f3e3379b8a4340 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Fri, 18 Jan 2013 15:59:18 +0100 Subject: [PATCH] Claim win against illegal move if opponent is computer 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 | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hachu.c b/hachu.c index ad1bd20..59fbacf 100644 --- a/hachu.c +++ b/hachu.c @@ -94,7 +94,7 @@ typedef struct { char *array, *reason; int bWidth, bHeight, bsize, zone, currentVariant; int stm, xstm, hashKeyH, hashKeyL, framePtr, msp, nonCapts, rootEval, retMSP, retFirst, retDep, pvPtr, level, cnt50, chuFlag=1, tenFlag, mobilityScore; -int nodes, startTime, tlim1, tlim2, repCnt; +int nodes, startTime, tlim1, tlim2, repCnt, comp; Move retMove, moveStack[10000], path[100], repStack[300], pv[1000], repeatMove[300]; #define X 36 /* slider */ @@ -2161,7 +2161,10 @@ printf("var %d\n",i); if(!strcmp(command, "memory")) { SetMemorySize(atoi(inBuf+7)); continue; } if(!strcmp(command, "ping")) { printf("pong%s", inBuf+4); continue; } // if(!strcmp(command, "")) { sscanf(inBuf, " %d", &); continue; } - if(!strcmp(command, "new")) { engineSide = BLACK; Init(V_CHESS); stm = Setup2(DEFAULT_FEN); maxDepth = MAXPLY; randomize = OFF; continue; } + if(!strcmp(command, "new")) { + engineSide = BLACK; Init(V_CHESS); stm = Setup2(DEFAULT_FEN); maxDepth = MAXPLY; randomize = OFF; comp = 0; + continue; + } if(!strcmp(command, "setboard")){ engineSide = NONE; stm = Setup2(inBuf+9); continue; } if(!strcmp(command, "easy")) { ponder = OFF; continue; } if(!strcmp(command, "hard")) { ponder = ON; continue; } @@ -2183,7 +2186,7 @@ printf("var %d\n",i); if(!strcmp(command, "l")) { pplist(); continue; } // ignored commands: if(!strcmp(command, "xboard")) { continue; } - if(!strcmp(command, "computer")){ continue; } + if(!strcmp(command, "computer")){ comp = 1; continue; } if(!strcmp(command, "name")) { continue; } if(!strcmp(command, "ics")) { continue; } if(!strcmp(command, "accepted")){ continue; } @@ -2195,6 +2198,7 @@ printf("var %d\n",i); int move = ParseMove(inBuf+9); if(move == INVALID) { if(reason) printf("Illegal move {%s}\n", reason); else printf("%s\n", reason="Illegal move"); + if(comp) PrintResult(stm, -INF); // against computer: claim } else { stm = MakeMove2(stm, move); ponderMove = INVALID; -- 1.7.0.4