Implement Ponder option
authorH.G. Muller <h.g.muller@hccnet.nl>
Sun, 16 Dec 2012 08:42:12 +0000 (09:42 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Sun, 16 Dec 2012 08:42:12 +0000 (09:42 +0100)
UCI2WB now makes the possibility to ponder subject to the engine reporting
the Ponder option, and sets this option according to the WB  ponder state.

UCI2WB.c

index e0570a2..7256061 100644 (file)
--- a/UCI2WB.c
+++ b/UCI2WB.c
@@ -32,7 +32,8 @@
 \r
 char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, pondering, suspended, 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, collect, nr, sm, inex, on[500]; char currMove[20], moveMap[500][10]; // for analyze mode\r
+int statDepth, statScore, statNodes, statTime, currNr, size, collect, nr, sm, inex, on[500];\r
+char currMove[20], moveMap[500][10], /* for analyze mode */ canPonder[20];\r
 \r
 FILE *toE, *fromE, *fromF;\r
 int pid;\r
@@ -237,6 +238,7 @@ Engine2GUI()
            if(p = strstr(line+6, " max "))  sscanf(p+1, "max %d", &max), *p = '\n';\r
            if(p = strstr(line+6, " default "))  sscanf(p+1, "default %[^\n]*", val), *p = '\n';\r
            if(p = strstr(line+6, " name ")) sscanf(p+1, "name %[^\n]*", name);\r
+           if(!strcmp(name, "Ponder") || !strcmp(name, "USI_Ponder")) { strcpy(canPonder, name); continue; }\r
            if(!strcmp(name, "Hash") || !strcmp(name, "USI_Hash")) {\r
                memory = oldMem = atoi(val); hasHash = 1; \r
                strcpy(hashOpt, name);\r
@@ -414,8 +416,8 @@ GUI2Engine()
        else if(!strcmp(command, "otim"))   sscanf(line+4, "%d", &hisTime), hisTime *= 10;\r
        else if(!strcmp(command, "post"))   post = 1;\r
        else if(!strcmp(command, "nopost")) post = 0;\r
-       else if(!strcmp(command, "easy"))   ponder = 0, StopPonder(pondering);\r
-       else if(!strcmp(command, "hard"))   ponder = 1, StartPonder();\r
+       else if(!strcmp(command, "easy") && !!*canPonder) ponder = 0, StopPonder(pondering), fprintf(toE, "setoption name %s value false\n", canPonder);\r
+       else if(!strcmp(command, "hard") && !!*canPonder) ponder = 1, fprintf(toE, "setoption name %s value true\n", canPonder), StartPonder();\r
        else if(!strcmp(command, "ping"))   pause = 1, fprintf(toE, "isready\n"), fflush(toE), Sync(PAUSE), printf("pong %s", line+5);\r
        else if(!strcmp(command, "memory")) sscanf(line, "memory %d", &memory);\r
        else if(!strcmp(command, "cores"))  sscanf(line, "cores %d", &cores);\r