// Set VARIANTS for in WinBoard variant feature. (With -s option this will always be reset to use "shogi".)\r
# define VARIANTS "normal,xiangqi"\r
\r
+#define DPRINT if(debug) printf\r
+\r
#define WHITE 0\r
#define BLACK 1\r
#define NONE 2\r
#define ANALYZE 3\r
\r
char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, pondering, ponder, post, hasHash, c, sc='c', *suffix;\r
-int mps, tc, inc, sTime, depth, myTime, hisTime, stm, computer = NONE, memory, oldMem=0, cores, moveNr, lastDepth, lastScore, startTime;\r
+int mps, tc, inc, sTime, depth, myTime, hisTime, stm, computer = NONE, memory, oldMem=0, cores, moveNr, lastDepth, lastScore, startTime, debug;\r
int statDepth, statScore, statNodes, statTime, currNr, size; char currMove[20]; // for analyze mode\r
\r
FILE *toE, *fromE;\r
{ // send the 'go' command to engine. Suffix by ponder.\r
int nr = moveNr + (ponder[0] != 0); // we ponder for one move ahead!\r
fprintf(toE, "\ngo btime %d wtime %d", stm == BLACK ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ sc=='s' ? myTime : hisTime);\r
- printf( "\n# go btime %d wtime %d", stm == BLACK ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ sc=='s' ? myTime : hisTime);\r
+ DPRINT( "\n# go btime %d wtime %d", stm == BLACK ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ sc=='s' ? myTime : hisTime);\r
if(sTime > 0) fprintf(toE, " movetime %d", sTime),printf(" movetime %d", sTime); else\r
if(mps) fprintf(toE, " movestogo %d", mps*(nr/(2*mps)+1)-nr/2),printf(" movestogo %d", mps*(nr/(2*mps)+1)-nr/2);\r
if(inc && !suffix) fprintf(toE, " winc %d binc %d", inc, inc),printf(" winc %d binc %d", inc, inc);\r
{\r
if(!pondering) return;\r
pause = 1;\r
- fprintf(toE, "stop\n"); fflush(toE); printf("# stop\n"); // note: 'pondering' remains set until engine acknowledges 'stop' with 'bestmove'\r
+ fprintf(toE, "stop\n"); fflush(toE); DPRINT("# stop\n"); // note: 'pondering' remains set until engine acknowledges 'stop' with 'bestmove'\r
Sync(PAUSE); // wait for engine to acknowledge 'stop' with 'bestmove'.\r
}\r
\r
{\r
int j;\r
fprintf(toE, "%s moves", iniPos);\r
- printf( "# %s moves", iniPos);\r
+ DPRINT( "# %s moves", iniPos);\r
for(j=0; j<moveNr; j++) fprintf(toE, " %s", move[j]),printf(" %s", move[j]);\r
}\r
\r
while((line[i] = x = fgetc(fromE)) != EOF && line[i] != '\n') i++;\r
line[++i] = 0;\r
if(x == EOF) exit(0);\r
-printf("# engine said: %s", line); fflush(stdout);\r
+ DPRINT("# engine said: %s", line); fflush(stdout);\r
sscanf(line, "%s", command);\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
if(p = strstr(line+9, "ponder")) {\r
if(computer != NONE && ponder) {\r
sscanf(p+7, "%s", move[moveNr]);\r
-printf("# ponder on %s\n", move[moveNr]);\r
+ DPRINT("# ponder on %s\n", move[moveNr]);\r
LoadPos(moveNr+1); // load position\r
// and set engine pondering\r
pondering = 1; lastDepth = 1;\r
int i, x;\r
\r
if(computer == stm || computer == ANALYZE) {\r
-printf("# start search\n");\r
+ DPRINT("# start search\n");\r
LoadPos(moveNr); // load position\r
// and set engine thinking (note USI swaps colors!)\r
startTime = GetTickCount();\r
if(pondering || computer == ANALYZE) {\r
if(pondering && !strcmp(command, move[moveNr])) { // ponder hit\r
pondering = 0; moveNr++; startTime = GetTickCount(); // clock starts running now\r
- fprintf(toE, "ponderhit\n"); printf("# ponderhit\n");\r
+ fprintf(toE, "ponderhit\n"); DPRINT("# ponderhit\n");\r
goto nomove;\r
}\r
StopPonder(1);\r
}\r
else if(!strcmp(command, "option")) {\r
char name[80], *p;\r
+ if(sscanf(line+7, "UCI2WB debug output=%d", &debug) == 1) ; else\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), printf("# setoption name %s value %s", line+7, p);\r
- } else fprintf(toE, "setoption name %s\n", line+7), printf("# setoption name %s\n", line+7);\r
+ fprintf(toE, "setoption name %s value %s", line+7, p); DPRINT("# setoption name %s value %s", line+7, p);\r
+ } else { fprintf(toE, "setoption name %s\n", line+7); DPRINT("# setoption name %s\n", line+7); }\r
}\r
else if(!strcmp(command, "protover")) {\r
printf("feature variants=\"%s\" setboard=1 usermove=1 debug=1 ping=1 reuse=0 done=0\n", sc=='s' ? "shogi,5x5+5_shogi" : VARIANTS);\r
+ printf("feature option=\"UCI2WB debug output -check %d\"\n", debug);\r
fprintf(toE, "u%ci\n", sc); // this prompts UCI engine for options\r
}\r
else if(!strcmp(command, "setboard")) {\r
char *dir = NULL, *p, *q; int e;\r
\r
if(argc == 2 && !strcmp(argv[1], "-v")) { printf("UCI2WB " VERSION " by H.G.Muller\n"); exit(0); }\r
+ if(argc > 1 && !strcmp(argv[1], "debug")) { debug = 1; argc--; argv++; }\r
if(argc > 1 && argv[1][0] == '-') { sc = argv[1][1]; argc--; argv++; }\r
- if(argc < 2) { printf("usage is: U%cI2WB [-s] <engine.exe> [<engine directory>]\n", sc-32); exit(-1); }\r
+ if(argc < 2) { printf("usage is: U%cI2WB [debug] [-s] <engine.exe> [<engine directory>]\n", sc-32); exit(-1); }\r
if(argc > 2) dir = argv[2];\r
if(argc > 3) suffix = argv[3];\r
\r