X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=blobdiff_plain;f=UCI2WB.c;h=c13ea347d0b6640c2b8f284992efd6725fdf2d32;hp=9e34c7c8219c6f8c58325eafddb794d4c4f7d13c;hb=e7c084cff327333c02190799fc3803c1a2b4fe74;hpb=c1946454644d9300609bb62499fecd8a7b0131e2 diff --git a/UCI2WB.c b/UCI2WB.c index 9e34c7c..c13ea34 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -9,7 +9,7 @@ /* of which you should have received a copy together with this file. */ /****************************************************************************/ -#define VERSION "2.2" +#define VERSION "2.3" #include #include @@ -30,9 +30,11 @@ #include // Set VARIANTS for in WinBoard variant feature. (With -s option this will always be reset to use "shogi".) -# define VARIANTS "normal,xiangqi" +#define VARIANTS "normal,xiangqi" +#define STDVARS "chess,chess960,crazyhouse,threecheck,giveaway,atomic,seirawan,shogi,xiangqi" #define DPRINT if(debug) printf +#define EPRINT(X) { char f[999]; sprintf X; DPRINT("%s", f); fprintf(toE, "%s", f + 2*(*f == '#')); /* strip optional # prefix */ } #define WHITE 0 #define BLACK 1 @@ -146,15 +148,14 @@ StartSearch(char *ponder) int t = (flob ? inc + myTime/40 : 1000*byo*(byo>0)); // byoyomi time if(sc == 'x') black = 1; else drawOffer = 0;// in UCCI 'black' refers to us and 'white' to opponent if(!x && drawOffer) ponder = " draw", drawOffer = 0; //pass draw offer only when not pondering - fprintf(toE, "\ngo%s %stime %d %stime %d", ponder, bTime, (black ? myTime : hisTime) - t, wTime, (!black ? myTime : hisTime) - t); - DPRINT( "\n# go%s %stime %d %stime %d", ponder, bTime, (black ? myTime : hisTime) - t, wTime, (!black ? myTime : hisTime) - t); - if(sTime > 0) { fprintf(toE, " movetime %d", sTime); DPRINT(" movetime %d", sTime); } else - if(mps) { fprintf(toE, " movestogo %d", mps*(nr/(2*mps)+1)-nr/2); DPRINT(" movestogo %d", mps*(nr/(2*mps)+1)-nr/2); } + EPRINT((f, "# go%s %stime %d %stime %d", ponder, bTime, (black ? myTime : hisTime) - t, wTime, (!black ? myTime : hisTime) - t)) + if(sTime > 0) EPRINT((f, " movetime %d", sTime)) else + if(mps) EPRINT((f, " movestogo %d", mps*(nr/(2*mps)+1)-nr/2)) if(flob || byo >= 0) sprintf(suffix, " byoyomi %d", t); // for engines running purely on byoyomi - if(inc && !*suffix) { fprintf(toE, " %s %d %s %d", wInc, inc, bInc, inc); DPRINT(" %s %d %s %d", wInc, inc, bInc, inc); } - if(depth > 0) { fprintf(toE, " depth %d", depth); DPRINT(" depth %d", depth); } - if(*suffix) { fprintf(toE, suffix, inc); DPRINT(suffix, inc); } - fprintf(toE, "\n"); DPRINT("\n"); + if(inc && !*suffix) EPRINT((f, " %s %d %s %d", wInc, inc, bInc, inc)) + if(depth > 0) EPRINT((f, " depth %d", depth)) + if(*suffix) EPRINT((f, suffix, inc)) + EPRINT((f, "\n")) } void @@ -162,7 +163,7 @@ StopPonder(int pondering) { if(!pondering) return; pause = 1; - fprintf(toE, "stop\n"); fflush(toE); DPRINT("# stop\n"); // note: 'pondering' remains set until engine acknowledges 'stop' with 'bestmove' + EPRINT((f, "# stop\n")) fflush(toE); // note: 'pondering' remains set until engine acknowledges 'stop' with 'bestmove' Sync(PAUSE); // wait for engine to acknowledge 'stop' with 'bestmove'. } @@ -176,9 +177,9 @@ LoadPos(int moveNr) stm = (!strstr(iniPos+4, " b ") ^ lastCapt & 1 ? 'w' : 'b'); sprintf(buf, "position fen %s", ToFEN(stm)); pos = buf; // send it as FEN (with "position" in UCCI!) } - fprintf(toE, "%s moves", pos); - DPRINT( "# %s moves", pos); - for(j=lastCapt; j 0) fprintf(toE, "setoption name UCI_Chess960 value true\n"); } + if(!strcmp(line+8, "fischerandom\n")) { frc |= 1; if(frc > 0) EPRINT((f, "# setoption name UCI_Chess960 value true\n")) } } else if(!strcmp(command, "undo") && (i=1) || !strcmp(command, "remove") && (i=2)) { - if(pondering || computer == ANALYZE) StopPonder(1); + if(pondering || computer == ANALYZE) StopPonder(1), searching = 0; moveNr = moveNr > i ? moveNr - i : 0; collect = (computer == ANALYZE); sm = 0; } else if(!strcmp(command, ".")) { @@ -509,7 +510,7 @@ GUI2Engine() inex = 1; line[strlen(line)-1] = sm = 0; // strip LF and clear sm flag for(i=1; i