void\r
StartSearch(char *ponder)\r
{ // send the 'go' command to engine. Suffix by ponder.\r
- char *draw = "draw ";\r
int x = (ponder[0] != 0); // during ponder stm is the opponent\r
int black = (stm == BLACK ^ x ^ sc == 's'); // set if our color is what the engine calls black\r
int nr = moveNr + x; // we ponder for one move ahead!\r
- if(sc == 'x') black = 1; else draw = ""; // in UCCI 'black' refers to us and 'white' to opponent\r
- drawOffer = 0;\r
- fprintf(toE, "\ngo%s %s%stime %d %stime %d", ponder, draw, bTime, black ? myTime : hisTime, wTime, !black ? myTime : hisTime);\r
- DPRINT( "\n# go%s %s%stime %d %stime %d", ponder, draw, bTime, black ? myTime : hisTime, wTime, !black ? myTime : hisTime);\r
+ if(sc == 'x') black = 1; else drawOffer = 0;// in UCCI 'black' refers to us and 'white' to opponent\r
+ if(!x && drawOffer) ponder = " draw", drawOffer = 0; //pass draw offer only when not pondering\r
+ fprintf(toE, "\ngo%s %stime %d %stime %d", ponder, bTime, black ? myTime : hisTime, wTime, !black ? myTime : hisTime);\r
+ DPRINT( "\n# go%s %stime %d %stime %d", ponder, bTime, black ? myTime : hisTime, wTime, !black ? myTime : hisTime);\r
if(sTime > 0) { fprintf(toE, " movetime %d", sTime); DPRINT(" movetime %d", sTime); } else\r
if(mps) { fprintf(toE, " movestogo %d", mps*(nr/(2*mps)+1)-nr/2); DPRINT(" movestogo %d", mps*(nr/(2*mps)+1)-nr/2); }\r
if(inc && !suffix) { fprintf(toE, " %s %d %s %d", wInc, inc, bInc, inc); DPRINT(" %s %d %s %d", wInc, inc, bInc, inc); }\r
if(!strcmp(command, "bestmove")) {\r
if(pause) { pondering = pause = 0; Sync(WAKEUP); continue; } // bestmove was reply to ponder miss or analysis result; ignore.\r
// move was a move to be played\r
- if((p = strstr(line+8, " draw")) && p != line+8) { *p = '\n'; printf("offer draw\n"); computer = NONE; } // UCCI\r
+ if(p = strstr(line+8, " draw")) *p = 0, printf("offer draw\n"); // UCCI\r
if(strstr(line+9, "resign")) { printf("resign\n"); computer = NONE; }\r
if(strstr(line+9, "(none)") || strstr(line+9, "null") ||\r
strstr(line+9, "0000")) { printf("%s\n", lastScore < -99999 ? "resign" : "1/2-1/2 {stalemate}"); computer = NONE; }\r
// when pondering we either continue the ponder search as normal search, or abort it\r
if(pondering || computer == ANALYZE) {\r
if(pondering && !strcmp(command, move[moveNr])) { // ponder hit\r
+ char *draw = drawOffer ? " draw" : ""; drawOffer = 0;\r
pondering = 0; moveNr++; startTime = GetTickCount(); // clock starts running now\r
- fprintf(toE, "ponderhit\n"); DPRINT("# ponderhit\n");\r
+ fprintf(toE, "ponderhit%s\n", draw); DPRINT("# ponderhit%s\n", draw);\r
goto nomove;\r
}\r
StopPonder(1);\r