X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=UCI2WB.c;h=cf506317485042a37575ddc470a896031444b68c;hb=ec2b5e72ae93d42e3556469abde71f90d2c09254;hp=256150c9cb906fed65ebada84b6c50230cdf6e42;hpb=99de6ab7fd6d624fbf821de5c2e42c1bbba6d914;p=uci2wb.git diff --git a/UCI2WB.c b/UCI2WB.c index 256150c..cf50631 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -79,9 +79,10 @@ Sync (int action) void StartSearch(char *ponder) { // send the 'go' command to engine. Suffix by ponder. - int nr = moveNr + (ponder[0] != 0); // we ponder for one move ahead! - fprintf(toE, "\ngo btime %d wtime %d", stm == BLACK ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ sc=='s' ? myTime : hisTime); - DPRINT( "\n# go btime %d wtime %d", stm == BLACK ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ sc=='s' ? myTime : hisTime); + int x = (ponder[0] != 0); + int nr = moveNr + x; // we ponder for one move ahead! + fprintf(toE, "\ngo btime %d wtime %d", stm == BLACK ^ x ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ x ^ sc=='s' ? myTime : hisTime); + DPRINT( "\n# go btime %d wtime %d", stm == BLACK ^ x ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ x ^ sc=='s' ? myTime : hisTime); if(sTime > 0) { fprintf(toE, " movetime %d", sTime); DPRINT(" movetime %d", sTime); } else if(mps) { fprintf(toE, " movestogo %d", mps*(nr/(2*mps)+1)-nr/2); DPRINT(" movestogo %d", mps*(nr/(2*mps)+1)-nr/2); } if(inc && !suffix) { fprintf(toE, " winc %d binc %d", inc, inc); DPRINT(" winc %d binc %d", inc, inc); } @@ -173,6 +174,7 @@ Engine2GUI() 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; // 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]); @@ -184,8 +186,7 @@ Engine2GUI() } else move[moveNr][0] = 0; Move4GUI(line+9); printf("move %s\n", line+9); // send move to GUI - if(lastScore == 100001 && iniPos[0] != 'f') { printf("%s {mate}\n", stm == WHITE ? "1-0" : "0-1"); computer = NONE; } - stm = WHITE+BLACK - stm; + if(lastScore == 100001 && iniPos[0] != 'f') { printf("%s {mate}\n", stm == BLACK ? "1-0" : "0-1"); computer = NONE; } } else if(!strcmp(command, "info")) { int d=0, s=0, t=0, n=0; @@ -385,7 +386,8 @@ GUI2Engine() } else if(!strcmp(command, "pause")) { if(computer == stm) myTime -= GetTickCount() - startTime; - suspended = 1 + pondering, StopPonder(1); // remember if we were pondering, and stop search ignoring bestmove + suspended = 1 + pondering; // remember if we were pondering, and stop search ignoring bestmove + StopPonder(pondering || computer == stm); } else if(!strcmp(command, "resume")) { if(suspended == 2) StartPonder(); // restart interrupted ponder search