Bump version to 4.0
[uci2wb.git] / UCI2WB.c
index ad897f5..a546859 100644 (file)
--- a/UCI2WB.c
+++ b/UCI2WB.c
@@ -9,7 +9,7 @@
 /* of which you should have received a copy together with this file.        */\r
 /****************************************************************************/\r
 \r
-#define VERSION "3.0"\r
+#define VERSION "4.0"\r
 \r
 #include <stdio.h>\r
 #include <stdlib.h>\r
@@ -294,17 +294,6 @@ HandleEngineOutput()
                }\r
                continue;\r
            }\r
-           if(collect && (pv = strstr(line+5, "currmove "))) {\r
-               if(p = strstr(line+5, "currmovenumber ")) {\r
-                   n = atoi(p+15);\r
-                   if(collect == 1 && n != 1) continue; // wait for move 1\r
-                   if(collect + (n == 1) > 2) { // done collecting\r
-                       if(inex && collect == 2) printf("%d 0 0 0 OK to exclude\n", lastDepth);\r
-                       collect = 3; continue;\r
-                   }\r
-                   collect = 2; on[nr=n] = 1; sscanf(pv+9, "%s", moveMap[n]); continue; // store move\r
-               }\r
-           }\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
@@ -313,8 +302,6 @@ HandleEngineOutput()
                if(p = strstr(line+4, " score "))      sscanf(p+7, "%d", &s), statScore = s;\r
                if(p = strstr(line+4, " nodes "))      sscanf(p+7, "%d", &n), statNodes = n;\r
                if(p = strstr(line+4, " time "))       sscanf(p+6, "%d", &t), t /= 10, statTime = t;\r
-               if(p = strstr(line+4, " currmove "))   sscanf(p+10,"%s", currMove);\r
-               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
@@ -324,6 +311,18 @@ HandleEngineOutput()
                    printf("%3d  %6d %6d %10d %s", lastDepth=d, lastScore=s, t, n, Convert(pv+4));\r
                } else if(s == -100000) lastScore = s; // when checkmated score is valid even without PV (which might not come)\r
            }\r
+           if(collect && (pv = strstr(line+4, " currmove "))) {\r
+               sscanf(pv+10,"%s", currMove);\r
+               if(p = strstr(line+4, " currmovenumber ")) {\r
+                   n = currNr = atoi(p+16);\r
+                   if(collect == 1 && n != 1) continue; // wait for move 1\r
+                   if(collect + (n == 1) > 2) { // done collecting\r
+                       if(inex && collect == 2) printf("%d 0 0 0 OK to exclude\n", lastDepth);\r
+                       collect = 3; continue;\r
+                   }\r
+                   collect = 2; on[nr=n] = 1; strcpy(moveMap[n], currMove); continue; // store move\r
+               }\r
+           }\r
        }\r
        else if(!strcmp(command, "option")) { // USI option: extract data fields\r
            char name[80], type[80], buf[1024], val[256], *q;\r
@@ -460,7 +459,7 @@ GUI2Engine()
        else if(!strcmp(command, "post"))  post = 1;\r
        else if(!strcmp(command, "nopost"))post = 0;\r
        else if(!strcmp(command, ".")) {\r
-           printf("stat01: %d %d %d %d 100 %s\n", statTime, statNodes, statDepth, 100-currNr, currMove);\r
+           printf("stat01: %d %d %d %d %d %s\n", statTime, statNodes, statDepth, nr-currNr, nr, currMove);\r
        }\r
        else if(!strcmp(command, "pause")) {\r
            if(computer == stm) myTime -= GetTickCount() - startTime;\r
@@ -468,8 +467,12 @@ GUI2Engine()
            StopSearch(1);\r
        }\r
        else if(!strcmp(command, "xboard")) ;\r
+       else if(!strcmp(command, "random")) ;\r
        else if(!strcmp(command, "accepted")) ;\r
        else if(!strcmp(command, "rejected")) ;\r
+       else if(!strcmp(command, "book")) ;\r
+       else if(!strcmp(command, "ics")) ;\r
+       else if(!strcmp(command, "hint")) ;\r
        else if(!strcmp(command, "computer")) comp = 1;\r
        else { //convert easy & hard to "option" after treating their effect on the adapter\r
          if(!strcmp(command, "easy")) {\r
@@ -542,10 +545,10 @@ DoCommand ()
            if(memory != oldMem && hasHash) EPRINT((f, "# setoption %s%s %s%d\n", nameWord, hashOpt, valueWord, memory))\r
            oldMem = memory;\r
            // we can set other options here\r
-           if(sc == 'x') { if(newGame) EPRINT((f, "# setoption newgame\n")) } else // optional in UCCI\r
            if(varOpt) EPRINT((f, "# setoption name UCI_Variant value chess\n"))\r
            EPRINT((f, "# isready\n")) fflush(toE);\r
            HandleEngineOutput(); // wait for readyok\r
+           if(sc == 'x') { if(newGame) EPRINT((f, "# setoption newgame\n")) } else // optional in UCCI\r
            EPRINT((f, "# u%cinewgame\n", sc)) fflush(toE);\r
        }\r
        else if(!strcmp(command, "option")) {\r
@@ -620,6 +623,7 @@ DoCommand ()
            computer = NONE;\r
        }\r
        else if(!strcmp(command, "quit"))   { EPRINT((f, "# quit\n")) fflush(toE), exit(atoi(line+4)); }\r
+       else printf("Error (unknown command): %s\n", command);\r
 \r
        fflush(stdout);\r
 }\r