Make suffix an array
[uci2wb.git] / UCI2WB.c
index fb80b68..632df6e 100644 (file)
--- a/UCI2WB.c
+++ b/UCI2WB.c
@@ -39,7 +39,7 @@
 #define NONE  2\r
 #define ANALYZE 3\r
 \r
-char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, pondering, suspended, ponder, post, hasHash, c, sc='c', *suffix, *variants;\r
+char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, pondering, suspended, ponder, post, hasHash, c, sc='c', suffix[81], *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, collect, nr, sm, inex, on[500], frc;\r
 char currMove[20], moveMap[500][10], /* for analyze mode */ canPonder[20], threadOpt[20];\r
@@ -147,9 +147,9 @@ StartSearch(char *ponder)
        DPRINT(    "\n# go%s %stime %d %stime %d", ponder, bTime, black ? myTime : hisTime, wTime, !black ? myTime : hisTime);\r
        if(sTime > 0) { fprintf(toE, " movetime %d", sTime); DPRINT(" movetime %d", sTime); } else\r
        if(mps) { fprintf(toE, " movestogo %d", mps*(nr/(2*mps)+1)-nr/2); DPRINT(" movestogo %d", mps*(nr/(2*mps)+1)-nr/2); }\r
-       if(inc && !suffix) { fprintf(toE, " %s %d %s %d", wInc, inc, bInc, inc); DPRINT(" %s %d %s %d", wInc, inc, bInc, inc); }\r
+       if(inc && !*suffix) { fprintf(toE, " %s %d %s %d", wInc, inc, bInc, inc); DPRINT(" %s %d %s %d", wInc, inc, bInc, inc); }\r
        if(depth > 0) { fprintf(toE, " depth %d", depth); DPRINT(" depth %d", depth); }\r
-        if(suffix) { fprintf(toE, suffix, inc); DPRINT(suffix, inc); }\r
+        if(*suffix) { fprintf(toE, suffix, inc); DPRINT(suffix, inc); }\r
        fprintf(toE, "\n"); DPRINT("\n");\r
 }\r
 \r
@@ -271,7 +271,7 @@ Engine2GUI()
            if(lastScore == 100001 && iniPos[0] != 'f') { printf("%s {mate}\n", stm == BLACK ? "1-0" : "0-1"); computer = NONE; }\r
        }\r
        else if(!strcmp(command, "info")) {\r
-           int d=0, s=0, t=0, n=0;\r
+           int d=0, s=0, t=(GetTickCount() - startTime)/10, n=1;\r
            char *pv;\r
            if(sscanf(line+5, "string times @ %c", &dummy) == 1) { printf("# %s", line+12); continue; }\r
            if(collect && (pv = strstr(line+5, "currmove "))) {\r
@@ -308,6 +308,9 @@ Engine2GUI()
            if(p = strstr(line+6, " default "))  sscanf(p+1, "default %[^\n]*", val), *p = '\n';\r
            if(!(p = strstr(line+6, " name "))) p = line+1; sscanf(p+6, "%[^\n]", name); // 'name' is omitted in UCCI\r
            if(!strcasecmp(name, "UCI_Chess960")) { frc=2; continue; }\r
+           if(frc< 0 && (strstr(name, "960") || strcasestr(name, "frc")) && !strcmp(type, "check")) {\r
+               fprintf(toE, "setoption name %s value true\n", name); strcpy(val, "true"); // set non-standard suspected FRC options\r
+           }\r
            if(!strcasecmp(name, "Threads")) { strcpy(threadOpt, name); continue; }\r
            if(!strcasecmp(name, "Ponder") || !strcasecmp(name, "USI_Ponder")) { strcpy(canPonder, name); continue; }\r
            if(!strcasecmp(name, "Hash") || !strcasecmp(name, "USI_Hash") || !strcasecmp(name, "hashsize")) {\r
@@ -338,8 +341,9 @@ Engine2GUI()
            if(buf[0]) printf("%s", buf);\r
        }\r
        else if(!strcmp(command, "id")) {\r
-           char name[256];\r
+           static char name[256], version[256];\r
            if(sscanf(line, "id name %[^\n]", name) == 1) printf("feature myname=\"%s (U%cI2WB)\"\n", name, sc-32);\r
+           if(sscanf(line, "id version %[^\n]", version) == 1 && *name) printf("feature myname=\"%s %s (U%cI2WB)\"\n", name, version, sc-32);\r
        }\r
        else if(!strcmp(command, "readyok")) { pause = 0; Sync(WAKEUP); } // resume processing of GUI commands\r
        else if(sc == 'x'&& !strcmp(command, "ucciok") || sscanf(command, "u%ciok", &c)==1 && c==sc) {\r
@@ -606,7 +610,7 @@ main(int argc, char **argv)
        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
-        if(argc > 3) suffix = argv[3];\r
+        if(argc > 3) strncpy(suffix, argv[3], 80);\r
 \r
         if(sc == 'x') nameWord = valueWord = bTime = "", wTime = "opp", bInc = "increment", wInc = "oppincrement", unit = 1000; // switch to UCCI keywords\r
        else if(sc == 'f' ) frc = -1, sc = 'c';   // UCI for unannounced Chess960\r