X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=blobdiff_plain;f=UCI2WB.c;h=5118c224f6ac7c4ee8ab1b420ebb17c218f13143;hp=41c71c81f97880a7f7de80da1b5d1f675a32d47d;hb=2b385df82d70d44518a167befa41e71fbd65c652;hpb=990ae69c6d5ff8468541372acc4c6fcb854f64e2 diff --git a/UCI2WB.c b/UCI2WB.c index 41c71c8..5118c22 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -260,7 +260,7 @@ HandleEngineOutput() if(strstr(line+9, "(none)") || strstr(line+9, "null") || strstr(line+9, "0000")) { printf("%s\n", lastScore < -99999 ? "resign" : "1/2-1/2 {stalemate}"); computer = NONE; } sscanf(line, "bestmove %s", move[moveNr++]); - myTime -= (GetTickCount() - startTime)*1.02 + inc; // update own clock, so we can give correct wtime, btime with ponder + 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; // first start a new ponder search, if pondering is on and we have a move to ponder on @@ -415,7 +415,7 @@ Move4Engine(char *m) } } -int DoCommand (); +void DoCommand (); char mySide; volatile char queue[10000], *qStart, *qEnd; @@ -424,7 +424,7 @@ LaunchSearch() { int i; - if((computer == stm || computer == ANALYZE && !searching) && !suspended) { + if((computer == stm || computer == ANALYZE && !searching && sm != 1) && !suspended) { DPRINT("# start search\n"); LoadPos(moveNr); fflush(stdout); // load position // and set engine thinking (note USI swaps colors!) @@ -520,14 +520,14 @@ GUI2Engine() } } -int +void DoCommand () { char line[1024], command[256], *p, *q, *r, type[99]; int i; p=line; while(qStart < qEnd && (*p++ = *qStart++) != '\n') {} *p = 0; - if(line[0] == '\n') return 0; + if(line[0] == '\n') return; sscanf(line, "%s", command); if(!strcmp(command, "new")) { @@ -594,7 +594,6 @@ DoCommand () int all = !strcmp(line+8, "all"), in = command[1] == 'n'; inex = 1; line[strlen(line)-1] = sm = 0; // strip LF and clear sm flag for(i=1; i 1) HandleEngineOutput(); // this could leave us (or fall through) pondering while(qStart == qEnd && searching) HandleEngineOutput(); // relay ponder output until command arrives Sync(PAUSE); // possibly wait for command silently if engine is idle - if(!DoCommand()) LaunchSearch(); + DoCommand(); LaunchSearch(); } }