#define STDVARS "chess,chess960,crazyhouse,threecheck,giveaway,atomic,seirawan,shogi,xiangqi"\r
\r
#define DPRINT if(debug) printf\r
+#define EPRINT(X) { char f[999]; sprintf X; DPRINT("%s", f); fprintf(toE, "%s", f + 2*(*f == '#')); /* strip optional # prefix */ }\r
\r
#define WHITE 0\r
#define BLACK 1\r
int t = (flob ? inc + myTime/40 : 1000*byo*(byo>0)); // byoyomi time \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, "go%s %stime %d %stime %d", ponder, bTime, (black ? myTime : hisTime) - t, wTime, (!black ? myTime : hisTime) - t);\r
- DPRINT( "# go%s %stime %d %stime %d", ponder, bTime, (black ? myTime : hisTime) - t, wTime, (!black ? myTime : hisTime) - t);\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
+ EPRINT((f, "# go%s %stime %d %stime %d", ponder, bTime, (black ? myTime : hisTime) - t, wTime, (!black ? myTime : hisTime) - t))\r
+ if(sTime > 0) EPRINT((f, " movetime %d", sTime)) else\r
+ if(mps) EPRINT((f, " movestogo %d", mps*(nr/(2*mps)+1)-nr/2))\r
if(flob || byo >= 0) sprintf(suffix, " byoyomi %d", t); // for engines running purely on byoyomi\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(depth > 0) { fprintf(toE, " depth %d", depth); DPRINT(" depth %d", depth); }\r
- if(*suffix) { fprintf(toE, suffix, inc); DPRINT(suffix, inc); }\r
- fprintf(toE, "\n"); DPRINT("\n");\r
+ if(inc && !*suffix) EPRINT((f, " %s %d %s %d", wInc, inc, bInc, inc))\r
+ if(depth > 0) EPRINT((f, " depth %d", depth))\r
+ if(*suffix) EPRINT((f, suffix, inc))\r
+ EPRINT((f, "\n"))\r
}\r
\r
void\r
{\r
if(!pondering) return;\r
pause = 1;\r
- fprintf(toE, "stop\n"); fflush(toE); DPRINT("# stop\n"); // note: 'pondering' remains set until engine acknowledges 'stop' with 'bestmove'\r
+ EPRINT((f, "# stop\n")) fflush(toE); // note: 'pondering' remains set until engine acknowledges 'stop' with 'bestmove'\r
Sync(PAUSE); // wait for engine to acknowledge 'stop' with 'bestmove'.\r
}\r
\r
stm = (!strstr(iniPos+4, " b ") ^ lastCapt & 1 ? 'w' : 'b');\r
sprintf(buf, "position fen %s", ToFEN(stm)); pos = buf; // send it as FEN (with "position" in UCCI!)\r
}\r
- fprintf(toE, "%s moves", pos);\r
- DPRINT( "# %s moves", pos);\r
- for(j=lastCapt; j<moveNr; j++) { fprintf(toE, " %s", move[j]); DPRINT(" %s", move[j]); }\r
- fprintf(toE, "\n"); DPRINT("\n");\r
+ EPRINT((f, "# %s moves", pos))\r
+ for(j=lastCapt; j<moveNr; j++) EPRINT((f, " %s", move[j]))\r
+ EPRINT((f, "\n"))\r
}\r
\r
void\r
// and set engine thinking (note USI swaps colors!)\r
startTime = GetTickCount(); mySide = stm; // remember side we last played for\r
if(computer == ANALYZE) {\r
- fprintf(toE, "go infinite"); DPRINT("# go infinite");\r
+ EPRINT((f, "# go infinite"))\r
if(sm & 1) { // some moves are disabled\r
- fprintf(toE, " searchmoves"); DPRINT(" searchmoves");\r
- for(i=1; i<nr; i++) if(on[i]) { fprintf(toE, " %s", moveMap[i]); DPRINT(" %s", moveMap[i]); }\r
+ EPRINT((f, " searchmoves"))\r
+ for(i=1; i<nr; i++) if(on[i]) EPRINT((f, " %s", moveMap[i]))\r
}\r
- fprintf(toE, "\n"); DPRINT("\n"); searching = 1; // suppresses spurious commands during analysis starting new searches\r
+ EPRINT((f, "\n")) searching = 1; // suppresses spurious commands during analysis starting new searches\r
} else { pause = 2; StartSearch(""); fflush(stdout); fflush(toE); Sync(PAUSE); } // block input during thinking\r
}\r
nomove:\r
if(pondering && !strcmp(command, move[moveNr])) { // ponder hit\r
char *draw = drawOffer ? " draw" : ""; drawOffer = 0;\r
pondering = 0; pause = 2; moveNr++; startTime = GetTickCount(); // clock starts running now\r
- fprintf(toE, "ponderhit%s\n", draw); DPRINT("# ponderhit%s\n", draw); fflush(toE); fflush(stdout);\r
+ EPRINT((f, "# ponderhit%s\n", draw)) fflush(toE); fflush(stdout);\r
Sync(PAUSE); // block input during thinking\r
goto nomove;\r
}\r
if(p = strchr(line, '=')) {\r
*p++ = 0;\r
if(strstr(checkOptions, line+7)) sprintf(p, "%s\n", atoi(p) ? "true" : "false");\r
- fprintf(toE, "setoption name %s value %s", line+7, p); DPRINT("# setoption %s%s %s%s", nameWord, line+7, valueWord, p);\r
- } else { fprintf(toE, "setoption %s%s\n", nameWord, line+7); DPRINT("# setoption %s%s\n", nameWord, line+7); }\r
+ EPRINT((f, "# setoption %s%s %s%s", nameWord, line+7, valueWord, p))\r
+ } else EPRINT((f, "# setoption %s%s\n", nameWord, line+7))\r
}\r
else if(!strcmp(command, "protover")) {\r
if(!variants) variants = sc=='s' ? "shogi,5x5+5_shogi" : VARIANTS;\r