Add support for robbobases
[uci2wb.git] / UCI2WB.c
index 534d988..05600ee 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,"\r
+#define EGT ",gaviotaTbPath,syzygyPath,nalimovPath,robbotripleBaseDirectory,robbototalBaseDirectory,"\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
@@ -54,9 +54,9 @@ volatile int logLen, sentLen;
 FILE *toE, *fromE, *fromF;\r
 int pid;\r
 \r
-#ifdef WIN32\r
 char *strcasestr (char *p, char *q) { while(*p) { char *r=p++, *s=q; while(tolower(*r++) == tolower(*s) && *s) s++; if(!*s) return p-1; } return NULL; }\r
 \r
+#ifdef WIN32\r
 WinPipe(HANDLE *hRd, HANDLE *hWr)\r
 {\r
   SECURITY_ATTRIBUTES saAttr;\r
@@ -328,6 +328,8 @@ Engine2GUI()
                if(p = strstr(line+4, " currmovenumber ")) sscanf(p+16,"%d", &currNr);\r
                if(pv = strstr(line+4, " pv ")) { // convert PV info to WB thinking output\r
                  if(d > maxDepth) maxDepth = d, mpvSP = 0; else if(d < maxDepth) continue; // ignore depth regressions\r
+                 if(p = strstr(line+4, " upperbound ")) strcat(p, "?\n"); else\r
+                 if(p = strstr(line+4, " lowerbound ")) strcat(p, "!\n");\r
                  for(i=0; i<mpvSP; i++) if(s == scores[i] && !strcmp(pvs[i], pv+4)) break; // check if duplicat\r
                  if(i >= mpvSP) strncpy(pvs[mpvSP], pv+4, 998), scores[mpvSP++] = s,       // emit as thinking output if not\r
                    printf("%3d  %6d %6d %10d %s", lastDepth=d, lastScore=s, t, n, Convert(pv+4));\r
@@ -358,7 +360,9 @@ 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-2*(buf[3]=='v')] = 0; strcat(egts, buf); continue; } // collect EGT formats\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
+           }\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
@@ -396,7 +400,7 @@ Engine2GUI()
                                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
-           if(*egts) { for(p=egts; *p = tolower(*p); p++); printf("feature egt=\"%s\"\n", egts+1); }\r
+           if(*egts) printf("feature egt=\"%s\"\n", egts+1);\r
            printf("feature smp=1 memory=%d done=1\n", hasHash);\r
            if(unit == 2) { unit = 1; EPRINT((f, "# setoption usemillisec true\n")) }\r
            Sync(WAKEUP); // done with options\r
@@ -589,7 +593,8 @@ 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
-           EPRINT((f, "# setoption name %s%sPath value %s\n", type, *type == 'g' ? "Tb" : "", command));\r
+            if(p = strstr(EGT, type)) strcpy(type, p), p = strchr(type, ','), *p = 0;\r
+           EPRINT((f, "# setoption name %s value %s\n", type, 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
@@ -692,6 +697,7 @@ main(int argc, char **argv)
 {\r
        char *dir = NULL, *p, *q; int e;\r
 \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 && !strcmp(argv[1], "-var")) { strcpy(varList+1, argv[2]); *varList = ','; argc-=2; argv+=2; }\r