Change UCI_Variant name from threecheck to 3check
[uci2wb.git] / UCI2WB.c
index 88b1d1c..534d988 100644 (file)
--- a/UCI2WB.c
+++ b/UCI2WB.c
@@ -9,7 +9,7 @@
 /* of which you should have received a copy together with this file.        */\r
 /****************************************************************************/\r
 \r
-#define VERSION "2.3"\r
+#define VERSION "3.0"\r
 \r
 #include <stdio.h>\r
 #include <stdlib.h>\r
@@ -31,8 +31,8 @@
 \r
 // Set VARIANTS for in WinBoard variant feature. (With -s option this will always be reset to use "shogi".)\r
 #define VARIANTS ",normal,xiangqi"\r
-#define STDVARS "chess,chess960,crazyhouse,threecheck,giveaway,atomic,seirawan,shogi,xiangqi"\r
-#define EGT ",syzygypath,nalimovpath,gaviotapath,"\r
+#define STDVARS "chess,chess960,crazyhouse,3check,giveaway,suicide,losers,atomic,seirawan,shogi,xiangqi"\r
+#define EGT ",gaviotatbpath,syzygypath,nalimovpath,"\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
@@ -358,7 +358,7 @@ Engine2GUI()
            }\r
            if(!strcasecmp(name, "newgame") && !strcmp(type, "button")) { newGame++; continue; }\r
            if(!strcasecmp(name, "usemillisec")) { unit = (!strcmp(val, "false") ? 2 : 1); continue; }\r
-           sprintf(buf, ",%s,", name); if(strcasestr(EGT, buf)) { buf[strlen(buf)-5] = 0; strcat(egts, buf); continue; } // collect EGT formats\r
+           sprintf(buf, ",%s,", name); if(strcasestr(EGT, buf)) { buf[strlen(buf)-5-2*(buf[3]=='v')] = 0; strcat(egts, buf); continue; } // collect EGT formats\r
            // pass on engine-defined option as WB option feature\r
            if(!strcmp(type, "filename")) type[4] = 0;\r
            else if(sc == 'c' && !strcmp(type, "string")) { // in UCI try to guess which strings are file or directory names\r
@@ -393,7 +393,6 @@ Engine2GUI()
            char *p = varList, *q = varList;\r
            while(*q && *q != '\n')  if(!strncmp(q, " var ", 5)) *p++ = ',', q +=5; // replace var keywords by commas\r
                                else if(!strncmp(q-1, " chess ", 7)) strcpy(p, "normal"), p += 6, q += 5; // 'chess' is called 'normal' in CECP\r
-                               else if(!strncmp(q-1, " threecheck", 11)) *p++ = '3', q += 5; // 'threecheck' is written '3check' in CECP\r
                                else *p++ = *q++; // copy other variant names unmodified\r
            if(frc) sprintf(p, ",normal,fischerandom"), printf("feature oocastle=%d\n", frc<0); // unannounced FRC uses O-O castling\r
            if(*varList) printf("feature variants=\"%s\"\n", varList+1); // from UCI_Variant combo and/or UCI_Chess960 check options\r
@@ -540,7 +539,7 @@ GUI2Engine()
            printf("feature setboard=1 usermove=1 debug=1 ping=1 name=1 reuse=0 exclude=1 pause=1 sigint=0 sigterm=0 done=0\n");\r
            printf("feature option=\"UCI2WB debug output -check %d\"\n", debug);\r
            if(sc == 's') printf("feature option=\"Floating Byoyomi -check %d\"\nfeature option=\"Byoyomi -spin %d -1 1000\"\n", flob, byo);\r
-           EPRINT((f, sc == 'x' ? "# ucci\n" : "u%ci\n", sc)) fflush(toE); // prompt UCI engine for options\r
+           EPRINT((f, sc == 'x' ? "# ucci\n" : "# u%ci\n", sc)) fflush(toE); // prompt UCI engine for options\r
            Sync(PAUSE); // wait for uciok\r
        }\r
        else if(!strcmp(command, "setboard")) {\r
@@ -557,7 +556,7 @@ GUI2Engine()
        }\r
        else if(!strcmp(command, "variant")) {\r
                if(varOpt) {\r
-                   EPRINT((f, "# setoption name UCI_Variant value %sucinewgame\nisready\n", strcmp(line+8, "3check\n") ? line+8 : "threecheck\n"))\r
+                   EPRINT((f, "# setoption name UCI_Variant value %sucinewgame\nisready\n", line+8))\r
                    fflush(toE); Sync(PAUSE);\r
                }\r
                if(!strcmp(line+8, "shogi\n")) size = 9, strcpy(iniPos, "position startpos");\r
@@ -588,7 +587,10 @@ GUI2Engine()
        else if(!strcmp(command, "ping"))   { /* static int done; if(!done) pause = 1, fprintf(toE, "isready\n"), fflush(toE), printf("# send isready\n"), fflush(stdout), Sync(PAUSE); done = 1;*/ printf("po%s", line+2); }\r
        else if(!strcmp(command, "memory")) sscanf(line, "memory %d", &memory);\r
        else if(!strcmp(command, "cores")&& !!*threadOpt) { sscanf(line, "cores %d", &cores); EPRINT((f, "# setoption %s%s %s%d\n", nameWord, threadOpt, valueWord, cores)) }\r
-       else if(!strcmp(command, "egtpath")){ sscanf(line, "egtpath %s %[^\n]", type, command); EPRINT((f, "# setoption name %sPath value %s\n", type,command)); }\r
+       else if(!strcmp(command, "egtpath")){\r
+           sscanf(line+8, "%s %[^\n]", type, command);\r
+           EPRINT((f, "# setoption name %s%sPath value %s\n", type, *type == 'g' ? "Tb" : "", command));\r
+       }\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, "name"))   { if(namOpt) EPRINT((f, "# setoption name UCI_Opponent value none none %s %s", comp ? "computer" : "human", line+5)) }\r