From bc61b527999e40d827ec95bd84edaf0090898973 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Tue, 23 Dec 2014 21:32:36 +0100 Subject: [PATCH] Block processing of CECP commands during thinking The GUI thread is blocked during thinking until a move is printed, so that ping can be instantly replied to when it is processed, without any need for isready/readyok. --- UCI2WB.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/UCI2WB.c b/UCI2WB.c index 9704071..2f450e8 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -245,7 +245,7 @@ Engine2GUI() DPRINT("# engine said: %s", line), fflush(stdout); if(sscanf(line, "%s", command) != 1) continue; if(!strcmp(command, "bestmove")) { - if(pause) { pondering = pause = 0; Sync(WAKEUP); continue; } // bestmove was reply to ponder miss or analysis result; ignore. + if(pause == 1) { pondering = pause = 0; Sync(WAKEUP); continue; } // bestmove was reply to ponder miss or analysis result; ignore. else if(pondering) { pondering = 0; printf("%d 0 0 0 UCI violation! Engine moves during ponder\n", lastDepth+1); continue; } // ignore ponder search // move was a move to be played if(p = strstr(line+8, " draw")) *p = 0, printf("offer draw\n"); // UCCI @@ -267,6 +267,7 @@ Engine2GUI() } else move[moveNr][0] = 0; Move4GUI(line+9); printf("move %s\n", line+9); // send move to GUI + if(pause) { pause = 0; Sync(WAKEUP); } // release commands that came in during think if(lastScore == 100001 && iniPos[0] != 'f') { printf("%s {mate}\n", stm == BLACK ? "1-0" : "0-1"); computer = NONE; } } else if(!strcmp(command, "info")) { @@ -387,7 +388,7 @@ GUI2Engine() } fprintf(toE, "\n"); DPRINT("\n"); // code for searchmoves goes here - } else StartSearch(""); + } else { pause = 2; StartSearch(""); fflush(stdout); fflush(toE); Sync(PAUSE); } // block input during thinking } nomove: fflush(toE); fflush(stdout); @@ -495,7 +496,7 @@ GUI2Engine() else if(!strcmp(command, "nopost")) post = 0; else if(!strcmp(command, "easy") && !!*canPonder) ponder = 0, StopPonder(pondering), fprintf(toE, "setoption %s%s %sfalse\n", nameWord, canPonder, valueWord); else if(!strcmp(command, "hard") && !!*canPonder) ponder = 1, fprintf(toE, "setoption %s%s %strue\n", nameWord, canPonder, valueWord), StartPonder(); - else if(!strcmp(command, "ping")) { static int done; if(!done) pause = 1, fprintf(toE, "isready\n"), fflush(toE), printf("# send isready\n"), fflush(stdout), Sync(PAUSE); done = 1; printf("pong %s", line+5); } + else if(!strcmp(command, "ping")) { /* static int done; if(!done) pause = 1, fprintf(toE, "isready\n"), fflush(toE), printf("# send isready\n"), fflush(stdout), Sync(PAUSE); done = 1;*/ printf("po%s", line+2); } else if(!strcmp(command, "memory")) sscanf(line, "memory %d", &memory); else if(!strcmp(command, "cores")&& !!*threadOpt) sscanf(line, "cores %d", &cores), fprintf(toE, "setoption %s%s %s%d\n", nameWord, threadOpt, valueWord, cores); else if(!strcmp(command, "sd")) sscanf(line, "sd %d", &depth); -- 1.7.0.4