/************************* UCI2WB by H.G.Muller ****************************/\r
\r
-#define VERSION "1.5"\r
+#define VERSION "1.6"\r
\r
#include <stdio.h>\r
#include <stdlib.h>\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
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
- if(depth > 0) fprintf(toE, " depth %d", depth),printf(" depth %d", depth);\r
- if(suffix) fprintf(toE, suffix, inc),printf(suffix, inc);\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, " winc %d binc %d", inc, inc); DPRINT(" winc %d binc %d", inc, 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, "%s\n", ponder);\r
- printf("%s\n", ponder);\r
+ DPRINT("%s\n", ponder);\r
}\r
\r
void\r
int j;\r
fprintf(toE, "%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
+ for(j=0; j<moveNr; j++) { fprintf(toE, " %s", move[j]); DPRINT(" %s", move[j]); }\r
}\r
\r
char *Convert(char *pv)\r
char line[1024], command[256];\r
\r
while(1) {\r
- int i=0, x; char *p;\r
+ int i=0, x; char *p, dummy;\r
\r
fflush(stdout); fflush(toE);\r
while((line[i] = x = fgetc(fromE)) != EOF && line[i] != '\n') i++;\r
line[++i] = 0;\r
if(x == EOF) exit(0);\r
- DPRINT("# 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
else if(!strcmp(command, "info")) {\r
int d=0, s=0, t=0, n=0;\r
char *pv;\r
+ if(sscanf(line+5, "string times @ %c", &dummy) == 1) { printf("# %s", line+12); continue; }\r
if(!post) continue;\r
- if(strstr(line, "info string ") == line) printf("%d 0 0 0 %s", lastDepth, line+12); else {\r
+ if(sscanf(line+5, "string %c", &dummy) == 1) printf("%d 0 0 0 %s", lastDepth, line+12); else {\r
if(p = strstr(line+4, " depth ")) sscanf(p+7, "%d", &d), statDepth = d;\r
if(p = strstr(line+4, " score cp ")) sscanf(p+10, "%d", &s), statScore = s; else\r
if(p = strstr(line+4, " score mate ")) sscanf(p+12, "%d", &s), s += s>0 ? 100000 : -100000, statScore = s; else\r
}\r
else if(!strcmp(command, "id")) {\r
char name[256];\r
- if(sscanf(line, "id name %s", name) == 1) printf("feature myname=\"%s (U%cI2WB)\"\n", name, sc-32);\r
+ if(sscanf(line, "id name %[^\n]", name) == 1) printf("feature myname=\"%s (U%cI2WB)\"\n", name, sc-32);\r
}\r
else if(!strcmp(command, "readyok")) { pause = 0; Sync(WAKEUP); } // resume processing of GUI commands\r
else if(sscanf(command, "u%ciok", &c)==1 && c==sc) printf("feature smp=1 memory=%d done=1\n", hasHash); // done with options\r