From: H.G.Muller Date: Sat, 8 Dec 2018 12:42:53 +0000 (+0100) Subject: Change StopPonder() into more general StopSearch() X-Git-Tag: v4.0~12 X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=commitdiff_plain;h=42d1fe296f371b87c4e9520c71e534ffe5569c77 Change StopPonder() into more general StopSearch() As StopPonder was only still used to unconditionally abort searches of any kind, it is changed into a general StopSearch() routine that handles the tasks that otherwise were performed before calling it. In particular it refrains from stopping a search if none is going on, and conditionally (based on its argument) sets 'searching' to idle if the move the search will come up with has to be ignored. --- diff --git a/UCI2WB.c b/UCI2WB.c index b901bbc..8715276 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -160,9 +160,10 @@ StartSearch(char *ponder) } void -StopPonder(int pondering) +StopSearch(int discard) { - if(!pondering) return; + if(!searching) return; + if(discard) searching = 0; // this causes bestmove to be ignored EPRINT((f, "# stop\n")) fflush(toE); // note: 'pondering' remains set until engine acknowledges 'stop' with 'bestmove' } @@ -460,7 +461,7 @@ GUI2Engine() else if(!strcmp(command, "pause")) { if(computer == stm) myTime -= GetTickCount() - startTime; suspended = 1 + (searching == 1); // remember if we were pondering, and stop search ignoring bestmove - if(searching) searching = 0, StopPonder(1); + StopSearch(1); } else { //convert easy & hard to "option" after treating their effect on the adapter if(!strcmp(command, "easy")) { @@ -493,7 +494,7 @@ GUI2Engine() EPRINT((f, "# ponderhit%s\n", draw)) fflush(toE); fflush(stdout); continue; } - searching = 0; StopPonder(1); + StopSearch(1); } strcpy(move[moveNr++], command); // possibly overwrites ponder move *qEnd++ = '\n'; Sync(WAKEUP); // make sure engine thread considers starting a search @@ -505,8 +506,8 @@ GUI2Engine() { if(searching == 3) { // command arrived during thinking; order abort for 'instant commands' if(!strcmp(command, "?") || !strcmp(command, "quit") || - !strcmp(command, "force") || !strcmp(command, "result")) StopPonder(1); - } else if(searching) searching = 0, StopPonder(1); // always abort pondering or analysis + !strcmp(command, "force") || !strcmp(command, "result")) StopSearch(0); + } else StopSearch(1); // always abort pondering or analysis // queue command for execution by engine thread if(qStart == qEnd) qStart = qEnd = queue;