X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=blobdiff_plain;f=UCI2WB.c;h=77b671b7b633cefba7715f06e5f0076b82ec0635;hp=ed3b884745ae795e0755ac0cc2c2f3323ea6ffc9;hb=d4c964cc8830407dbc9efa12a1d50e4ce48b711a;hpb=7baf116260ab2945f3dd74ee7bc93bd77cad5bc7 diff --git a/UCI2WB.c b/UCI2WB.c index ed3b884..77b671b 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -1,6 +1,6 @@ /************************* UCI2WB by H.G.Muller ****************************/ -#define VERSION "1.10" +#define VERSION "2.0" #include #include @@ -148,7 +148,7 @@ void StopPonder(int pondering) { if(!pondering) return; - pause = 1; + pause = 2; fprintf(toE, "stop\n"); fflush(toE); DPRINT("# stop\n"); // note: 'pondering' remains set until engine acknowledges 'stop' with 'bestmove' Sync(PAUSE); // wait for engine to acknowledge 'stop' with 'bestmove'. } @@ -237,6 +237,7 @@ Engine2GUI() 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. + 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 if(strstr(line+9, "resign")) { printf("resign\n"); computer = NONE; } @@ -382,7 +383,7 @@ GUI2Engine() nomove: fflush(toE); fflush(stdout); i = 0; while((x = getchar()) != EOF && (line[i] = x) != '\n') i++; - line[++i] = 0; if(x == EOF) { printf("# EOF\n"); exit(-1); } + line[++i] = 0; if(x == EOF) { printf("# EOF\n"); fprintf(toE, "quit\n"); exit(-1); } sscanf(line, "%s", command); if(!strcmp(command, "new")) { computer = BLACK; moveNr = 0; depth = -1; move[0][0] = 0; @@ -603,7 +604,7 @@ main(int argc, char **argv) #ifdef WIN32 CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) Engine2GUI, (LPVOID) NULL, 0, &thread_id); #else - { pthread_t t; signal(SIGINT, SIG_IGN); pthread_create(&t, NULL, Engine2GUI, NULL); } + { pthread_t t; signal(SIGINT, SIG_IGN); signal(SIGTERM, SIG_IGN); pthread_create(&t, NULL, Engine2GUI, NULL); } #endif // handle GUI->engine traffic in original thread