From 4c43c5722cf24b0cd44a9fe1f1eb6ad6c501d345 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Mon, 29 Jan 2018 11:43:02 +0100 Subject: [PATCH] Add support for robbobases The UCI options RobboTripleBaseDirectory and RobboTotalBaseDirectory are now recogized as defining the egtpath for flavors 'robbtripple' and 'robbototal', respectively. For this the general EGT-handling code had to be adapted to be able to append 'BaseDirectory' instead of '(Tb)Path' to the flavor for setting the option, and clipping this off for extracting the flavor name. This is achieved by using the part of the standard option in the list of EGT formats up to the first capital as CECP flavor name, and match the flavor name in the egtpath command with the list, to retrieve the full name from there. --- UCI2WB.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/UCI2WB.c b/UCI2WB.c index 534d988..05600ee 100644 --- 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".) #define VARIANTS ",normal,xiangqi" #define STDVARS "chess,chess960,crazyhouse,3check,giveaway,suicide,losers,atomic,seirawan,shogi,xiangqi" -#define EGT ",gaviotatbpath,syzygypath,nalimovpath," +#define EGT ",gaviotaTbPath,syzygyPath,nalimovPath,robbotripleBaseDirectory,robbototalBaseDirectory," #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 */ } @@ -54,9 +54,9 @@ volatile int logLen, sentLen; FILE *toE, *fromE, *fromF; int pid; -#ifdef WIN32 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; } +#ifdef WIN32 WinPipe(HANDLE *hRd, HANDLE *hWr) { SECURITY_ATTRIBUTES saAttr; @@ -328,6 +328,8 @@ Engine2GUI() if(p = strstr(line+4, " currmovenumber ")) sscanf(p+16,"%d", &currNr); if(pv = strstr(line+4, " pv ")) { // convert PV info to WB thinking output if(d > maxDepth) maxDepth = d, mpvSP = 0; else if(d < maxDepth) continue; // ignore depth regressions + if(p = strstr(line+4, " upperbound ")) strcat(p, "?\n"); else + if(p = strstr(line+4, " lowerbound ")) strcat(p, "!\n"); for(i=0; i= mpvSP) strncpy(pvs[mpvSP], pv+4, 998), scores[mpvSP++] = s, // emit as thinking output if not printf("%3d %6d %6d %10d %s", lastDepth=d, lastScore=s, t, n, Convert(pv+4)); @@ -358,7 +360,9 @@ Engine2GUI() } if(!strcasecmp(name, "newgame") && !strcmp(type, "button")) { newGame++; continue; } if(!strcasecmp(name, "usemillisec")) { unit = (!strcmp(val, "false") ? 2 : 1); continue; } - sprintf(buf, ",%s,", name); if(strcasestr(EGT, buf)) { buf[strlen(buf)-5-2*(buf[3]=='v')] = 0; strcat(egts, buf); continue; } // collect EGT formats + sprintf(buf, ",%s,", name); if(p = strcasestr(EGT, buf)) { // collect EGT formats + strcpy(buf, p); for(p=buf; *++p >='a';){} *p = 0; strcat(egts, buf); continue; // clip at first non-lower-case + } // pass on engine-defined option as WB option feature if(!strcmp(type, "filename")) type[4] = 0; else if(sc == 'c' && !strcmp(type, "string")) { // in UCI try to guess which strings are file or directory names @@ -396,7 +400,7 @@ Engine2GUI() else *p++ = *q++; // copy other variant names unmodified if(frc) sprintf(p, ",normal,fischerandom"), printf("feature oocastle=%d\n", frc<0); // unannounced FRC uses O-O castling if(*varList) printf("feature variants=\"%s\"\n", varList+1); // from UCI_Variant combo and/or UCI_Chess960 check options - if(*egts) { for(p=egts; *p = tolower(*p); p++); printf("feature egt=\"%s\"\n", egts+1); } + if(*egts) printf("feature egt=\"%s\"\n", egts+1); printf("feature smp=1 memory=%d done=1\n", hasHash); if(unit == 2) { unit = 1; EPRINT((f, "# setoption usemillisec true\n")) } Sync(WAKEUP); // done with options @@ -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)) } else if(!strcmp(command, "egtpath")){ sscanf(line+8, "%s %[^\n]", type, command); - EPRINT((f, "# setoption name %s%sPath value %s\n", type, *type == 'g' ? "Tb" : "", command)); + if(p = strstr(EGT, type)) strcpy(type, p), p = strchr(type, ','), *p = 0; + EPRINT((f, "# setoption name %s value %s\n", type, command)); } else if(!strcmp(command, "sd")) sscanf(line, "sd %d", &depth); else if(!strcmp(command, "st")) sscanf(line, "st %d", &sTime), sTime = 1000*sTime - 30, inc = 0, sTime /= unit; @@ -692,6 +697,7 @@ main(int argc, char **argv) { char *dir = NULL, *p, *q; int e; + if(argc == 2 && !strcmp(argv[1], "-v")) { printf("UCI2WB " VERSION " by H.G.Muller\n"); exit(0); } if(argc > 1 && !strcmp(argv[1], "debug")) { debug = 1; argc--; argv++; } if(argc > 1 && !strcmp(argv[1], "-var")) { strcpy(varList+1, argv[2]); *varList = ','; argc-=2; argv+=2; } -- 1.7.0.4