X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=blobdiff_plain;f=UCI2WB.c;h=1632b818e5f20be6680d7b15f6e47626b22571fe;hp=5118c224f6ac7c4ee8ab1b420ebb17c218f13143;hb=df071f0901dc34959be92976afde6dd7054dd8ad;hpb=2b385df82d70d44518a167befa41e71fbd65c652 diff --git a/UCI2WB.c b/UCI2WB.c index 5118c22..1632b81 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -262,7 +262,7 @@ HandleEngineOutput() sscanf(line, "bestmove %s", move[moveNr++]); myTime -= (GetTickCount() - startTime)*1.02 - inc; // update own clock, so we can give correct wtime, btime with ponder if(mps && ((moveNr+1)/2) % mps == 0) myTime += tc; if(sTime) myTime = sTime; // new session or move starts - stm = WHITE+BLACK - stm; + stm = WHITE+BLACK - stm; searching = 0; // first start a new ponder search, if pondering is on and we have a move to ponder on if(p = strstr(line+9, "ponder")) { sscanf(p+7, "%s", move[moveNr]); @@ -276,7 +276,7 @@ HandleEngineOutput() printf("move %s\n", line+9); // send move to GUI if(move[moveNr][0]) printf("Hint: %s\n", move[moveNr]); if(lastScore == 100001 && iniPos[0] != 'f') { printf("%s {mate}\n", stm == BLACK ? "1-0" : "0-1"); computer = NONE; } - return; + fflush(stdout); return; } else if(!strcmp(command, "info")) { int d=0, s=0, t=(GetTickCount() - startTime)/10, n=1; @@ -388,11 +388,12 @@ HandleEngineOutput() else if(!strncmp(q-1, " chess ", 7)) strcpy(p, "normal"), p += 6, q += 5; // 'chess' is called 'normal' in CECP else *p++ = *q++; // copy other variant names unmodified if(frc) sprintf(p, ",normal,fischerandom"), printf("feature oocastle=%d\n", frc<0); // unannounced FRC uses O-O castling - if(*varList) printf("feature variants=\"%s\"\n", varList+1); // from UCI_Variant combo and/or UCI_Chess960 check options + if(!*varList) strcpy(varList, sc=='s' ? ",shogi,5x5+5_shogi" : VARIANTS); // without clue guess liberally + printf("feature variants=\"%s\"\n", varList+1); // from UCI_Variant combo and/or UCI_Chess960 check options if(*egts) printf("feature egt=\"%s\"\n", egts+1); printf("feature smp=1 memory=%d done=1\n", hasHash); if(unit == 2) { unit = 1; EPRINT((f, "# setoption usemillisec true\n")) } - return; // done with options + fflush(stdout); return; // done with options } } } @@ -452,6 +453,7 @@ GUI2Engine() fflush(toE); fflush(stdout); if(!ReadLine(stdin, line)) printf("# EOF\n"), sprintf(line, "quit -1\n"); sscanf(line, "%s", command); + DPRINT("# %s searching=%d\n", command, searching); if(!strcmp(command, "usermove")) { difficult--; break; } // for efficiency during game play, moves, time & otim are tried first else if(!strcmp(command, "time")) sscanf(line+4, "%d", &myTime), myTime = (10*myTime)/unit; else if(!strcmp(command, "otim")) sscanf(line+4, "%d", &hisTime), hisTime = (10*hisTime)/unit; @@ -473,7 +475,7 @@ GUI2Engine() else if(!strcmp(command, "hard")) { if(*canPonder) ponder = 1, sprintf(command, "option"), sprintf(line, "option %s=1\n", canPonder); else continue; } - else if(!strcmp(command, "option")) { + if(!strcmp(command, "option")) { if(sscanf(line+7, "UCI2WB debug output=%d", &debug) == 1) ; else if(sscanf(line+7, "ponder always=%d", &ponderAlways) == 1) ; else if(sscanf(line+7, "Floating Byoyomi=%d", &flob) == 1) ; else @@ -528,7 +530,7 @@ DoCommand () p=line; while(qStart < qEnd && (*p++ = *qStart++) != '\n') {} *p = 0; if(line[0] == '\n') return; - sscanf(line, "%s", command); + sscanf(line, "%s", command); DPRINT("# command %s\n", command), fflush(stdout); if(!strcmp(command, "new")) { computer = BLACK; moveNr = 0; depth = -1; move[0][0] = 0; @@ -557,7 +559,6 @@ DoCommand () tc = (60*tc + sec)*1000; inc *= 1000; sTime = 0; tc /= unit; inc /= unit; } else if(!strcmp(command, "protover")) { - if(!varList[0]) strcpy(varList, sc=='s' ? ",shogi,5x5+5_shogi" : VARIANTS); printf("feature setboard=1 usermove=1 debug=1 ping=1 name=1 reuse=0 exclude=1 pause=1 sigint=0 sigterm=0 done=0\n"); printf("feature option=\"UCI2WB debug output -check %d\"\n", debug); printf("feature option=\"ponder always -check %d\"\n", ponderAlways); @@ -617,6 +618,8 @@ DoCommand () computer = NONE; } else if(!strcmp(command, "quit")) { EPRINT((f, "# quit\n")) fflush(toE), exit(atoi(line+4)); } + + fflush(stdout); } void *