X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=blobdiff_plain;f=UCI2WB.c;h=b9df43c4c1e53bfc99c1ed79af265c4f22f4f919;hp=1fc24fc2a3e8beeedc4249d49896420f7128bc19;hb=9e92f9f1e4e601912bd40334c9f89677b9b65f23;hpb=47b967aa38dcb5db60229931abf391f42c2abf1f diff --git a/UCI2WB.c b/UCI2WB.c index 1fc24fc..b9df43c 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -441,12 +441,9 @@ char mySide; char queue[10000], *qStart, *qEnd; void -GUI2Engine() +LaunchSearch() { - char line[256], command[256], *p; - - while(1) { - int i, difficult; + int i; if((computer == stm || computer == ANALYZE && !searching) && !suspended) { DPRINT("# start search\n"); @@ -462,7 +459,16 @@ GUI2Engine() EPRINT((f, "\n")) searching = 2; // suppresses spurious commands during analysis starting new searches } else pause = 2, searching = 3, StartSearch(""); // request suspending of input processing while thinking } else if(ponderAlways && computer == NONE) move[moveNr][0] = 0, StartPonder(moveNr-1); - nomove: +} + +void +GUI2Engine() +{ + char line[256], command[256], *p; + + while(1) { + int i, difficult; + for(difficult=0; !difficult; ) { // read and handle commands that can (or must) be handled during thinking fflush(toE); fflush(stdout); if(!ReadLine(stdin, line)) printf("# EOF\n"), sprintf(line, "quit -1\n"); @@ -517,18 +523,18 @@ GUI2Engine() searching = 0; pause = 2; moveNr++; startTime = GetTickCount(); // clock starts running now EPRINT((f, "# ponderhit%s\n", draw)) fflush(toE); fflush(stdout); searching = 3; // request blocking input during thinking - goto nomove; + continue; } StopPonder(1); searching = 0; } strcpy(move[moveNr++], command); // possibly overwrites ponder move - continue; - } + } else if(!strcmp(command, "resume")) { searching = 0; if(suspended == 2) StartPonder(moveNr); // restart interrupted ponder search - suspended = 0; continue; // causes thinking to start in normal way if on move or analyzing - } + suspended = 0; // causes thinking to start in normal way if on move or analyzing + } else + { if(searching == 3) { // command arrived during thinking; order abort for 'instant commands' if(!strcmp(command, "?") || !strcmp(command, "quit") || !strcmp(command, "force") || !strcmp(command, "result")) { EPRINT((f, "# stop\n")); fflush(toE); } @@ -536,7 +542,10 @@ GUI2Engine() } if(qStart == qEnd) qStart = qEnd = queue; p = line; while(qEnd < queue+10000 && (*qEnd++ = *p++) != '\n') {} - if(DoCommand()) goto nomove; + if(DoCommand()) continue; + } + + LaunchSearch(); // start a search if we need one } }