Make supported variants run-time configurable
[uci2wb.git] / UCI2WB.c
index 53b2f19..7f90ba6 100644 (file)
--- a/UCI2WB.c
+++ b/UCI2WB.c
@@ -1,6 +1,6 @@
 /************************* UCI2WB by H.G.Muller ****************************/\r
 \r
-#define VERSION "1.6"\r
+#define VERSION "1.7"\r
 \r
 #include <stdio.h>\r
 #include <stdlib.h>\r
@@ -30,7 +30,7 @@
 #define NONE  2\r
 #define ANALYZE 3\r
 \r
-char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, pondering, ponder, post, hasHash, c, sc='c', *suffix;\r
+char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, pondering, ponder, post, hasHash, c, sc='c', *suffix, *variants;\r
 int mps, tc, inc, sTime, depth, myTime, hisTime, stm, computer = NONE, memory, oldMem=0, cores, moveNr, lastDepth, lastScore, startTime, debug;\r
 int statDepth, statScore, statNodes, statTime, currNr, size; char currMove[20]; // for analyze mode\r
 \r
@@ -178,6 +178,7 @@ Engine2GUI()
        else if(!strcmp(command, "info")) {\r
            int d=0, s=0, t=0, n=0;\r
            char *pv;\r
+           if(sscanf(line+5, "string times @ %c", &dummy) == 1) { printf("# %s", line+12); continue; }\r
            if(!post) continue;\r
            if(sscanf(line+5, "string %c", &dummy) == 1) printf("%d 0 0 0 %s", lastDepth, line+12); else {\r
                if(p = strstr(line+4, " depth "))      sscanf(p+7, "%d", &d), statDepth = d;\r
@@ -309,7 +310,8 @@ GUI2Engine()
            } else { fprintf(toE, "setoption name %s\n", line+7); DPRINT("# setoption name %s\n", line+7); }\r
        }\r
        else if(!strcmp(command, "protover")) {\r
-           printf("feature variants=\"%s\" setboard=1 usermove=1 debug=1 ping=1 reuse=0 done=0\n", sc=='s' ? "shogi,5x5+5_shogi" : VARIANTS);\r
+           if(!variants) variants = sc=='s' ? "shogi,5x5+5_shogi" : VARIANTS;\r
+           printf("feature variants=\"%s\" setboard=1 usermove=1 debug=1 ping=1 reuse=0 done=0\n", variants);\r
            printf("feature option=\"UCI2WB debug output -check %d\"\n", debug);\r
            fprintf(toE, "u%ci\n", sc); // this prompts UCI engine for options\r
        }\r
@@ -349,7 +351,7 @@ GUI2Engine()
        else if(!strcmp(command, "memory")) sscanf(line, "memory %d", &memory);\r
        else if(!strcmp(command, "cores"))  sscanf(line, "cores %d", &cores);\r
        else if(!strcmp(command, "sd"))     sscanf(line, "sd %d", &depth);\r
-       else if(!strcmp(command, "st"))     sscanf(line, "st %d", &sTime), sTime *= 1000, inc = 0;\r
+       else if(!strcmp(command, "st"))     sscanf(line, "st %d", &sTime), sTime = 1000*sTime - 30, inc = 0;\r
        else if(!strcmp(command, "quit"))   fprintf(toE, "quit\n"), fflush(toE), exit(0);\r
     }\r
 }\r
@@ -445,6 +447,7 @@ main(int argc, char **argv)
 \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")) { variants = argv[2]; argc-=2; argv+=2; }\r
        if(argc > 1 && argv[1][0] == '-') { sc = argv[1][1]; argc--; argv++; }\r
        if(argc < 2) { printf("usage is: U%cI2WB [debug] [-s] <engine.exe> [<engine directory>]\n", sc-32); exit(-1); }\r
        if(argc > 2) dir = argv[2];\r