Implement extended UCI info string variant option
[uci2wb.git] / UCI2WB.c
index 05600ee..9d568f7 100644 (file)
--- a/UCI2WB.c
+++ b/UCI2WB.c
@@ -32,7 +32,7 @@
 // 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,3check,giveaway,suicide,losers,atomic,seirawan,shogi,xiangqi"\r
-#define EGT ",gaviotaTbPath,syzygyPath,nalimovPath,robbotripleBaseDirectory,robbototalBaseDirectory,"\r
+#define EGT ",gaviotaTbPath,syzygyPath,nalimovPath,robbotripleBaseDirectory,robbototalBaseDirectory,bitbases path,"\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
@@ -302,7 +302,15 @@ Engine2GUI()
            char *pv, varName[80];\r
            if(sscanf(line+5, "string times @ %c", &dummy) == 1) { printf("# %s", line+12); continue; }\r
            if(sscanf(line+5, "string variant %s", varName) == 1) {\r
-               if(!strstr(STDVARS, varName) && (p = strstr(line+18, " startpos "))) printf("setup (-) 8x8+0_fairy %s", p+10);\r
+               if(!strstr(STDVARS, varName)) {\r
+                   int files = 8, ranks = 8, hand = 0; char parent[80];\r
+                   if(p = strstr(line+18, " files ")) sscanf(p+7, "%d", &files);\r
+                   if(p = strstr(line+18, " ranks ")) sscanf(p+7, "%d", &ranks);\r
+                   if(p = strstr(line+18, " pocket ")) sscanf(p+8, "%d", &hand);\r
+                   if(p = strstr(line+18, " template ")) sscanf(p+10, "%s", parent); else strcpy(parent, "fairy");\r
+                   if(p = strstr(line+18, " startpos "))\r
+                       printf("setup (-) %dx%d+%d_%s %s", files, ranks, hand, parent, p+10);\r
+               }\r
                continue;\r
            }\r
            if(collect && (pv = strstr(line+5, "currmove "))) {\r
@@ -361,7 +369,7 @@ Engine2GUI()
            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(p = strcasestr(EGT, buf)) { // collect EGT formats\r
-               strcpy(buf, p); for(p=buf; *++p >='a';){} *p = 0; strcat(egts, buf); continue; // clip at first non-lower-case\r
+               strcpy(buf, p); for(p=buf; *++p >='a';){} if(*p == ' ') strcpy(buf, ",scorpio"); *p = 0; strcat(egts, buf); continue; // clip at first non-lower-case\r
            }\r
            // pass on engine-defined option as WB option feature\r
            if(!strcmp(type, "filename")) type[4] = 0;\r
@@ -593,7 +601,7 @@ GUI2Engine()
        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")){\r
            sscanf(line+8, "%s %[^\n]", type, command);\r
-            if(p = strstr(EGT, type)) strcpy(type, p), p = strchr(type, ','), *p = 0;\r
+            if(p = strstr(EGT, type)) strcpy(type, p), p = strchr(type, ','), *p = 0; else strcpy(type, "bitbases path");\r
            EPRINT((f, "# setoption name %s value %s\n", type, command));\r
        }\r
        else if(!strcmp(command, "sd"))     sscanf(line, "sd %d", &depth);\r