char currMove[20], moveMap[500][10], /* for analyze mode */ canPonder[20], threadOpt[20];\r
char board[100]; // XQ board for UCCI\r
char *nameWord = "name ", *valueWord = "value ", *wTime = "w", *bTime = "b", *wInc = "winc", *bInc = "binc", newGame; // keywords that differ in UCCI\r
-int unit = 1;\r
+int unit = 1, drawOffer;\r
\r
FILE *toE, *fromE, *fromF;\r
int pid;\r
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; // in UCCI 'black' refers to us and 'white' to opponent\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(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(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(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
else if(!strcmp(command, "cores")&& !!*threadOpt) sscanf(line, "cores %d", &cores), fprintf(toE, "setoption %s%s %s%d\n", nameWord, threadOpt, valueWord, cores);\r
else if(!strcmp(command, "sd")) sscanf(line, "sd %d", &depth);\r
else if(!strcmp(command, "st")) sscanf(line, "st %d", &sTime), sTime = 1000*sTime - 30, inc = 0, sTime /= unit;\r
+ else if(!strcmp(command, "offer")) drawOffer = 1;\r
else if(!strcmp(command, "quit")) fprintf(toE, "quit\n"), fflush(toE), exit(0);\r
}\r
}\r