Let LaunchSearch() also start ponder search
[uci2wb.git] / UCI2WB.c
index 0a1de9f..7cdf340 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
@@ -188,6 +188,7 @@ StartPonder(int moveNr)
        if(!move[moveNr][0]) return; // no ponder move\r
        LoadPos(moveNr+1);\r
        searching = 1; lastDepth = 1;\r
+       DPRINT("# ponder on %s\n", move[moveNr]);\r
        StartSearch(" ponder");\r
 }\r
 \r
@@ -266,10 +267,7 @@ HandleEngineOutput()
            // first start a new ponder search, if pondering is on and we have a move to ponder on\r
            if(p = strstr(line+9, "ponder")) {\r
              sscanf(p+7, "%s", move[moveNr]);\r
-             if(computer != NONE && ponder) {\r
-               DPRINT("# ponder on %s\n", move[moveNr]);\r
-               StartPonder(moveNr);\r
-             }\r
+             if(computer != NONE && ponder) StartPonder(moveNr);\r
              p[-1] = '\n'; *p = 0; // strip off ponder move\r
            } else move[moveNr][0] = 0;\r
            Move4GUI(line+9);\r
@@ -371,6 +369,7 @@ HandleEngineOutput()
                    sprintf(buf + strlen(buf), "%s%s%s", min++ ? " /// " : " ", strcmp(type, val) ? "" : "*", val);\r
                }\r
                strcat(q, "\"\n");\r
+\r
            }\r
            else buf[0] = 0; // ignore unrecognized option types\r
            if(buf[0]) printf("%s", buf);\r
@@ -424,7 +423,9 @@ LaunchSearch()
 {\r
     int i;\r
 \r
-       if((computer == stm || computer == ANALYZE && !searching && sm != 1) && !suspended) {\r
+    if(suspended || searching) return;\r
+\r
+       if(computer == stm || computer == ANALYZE && sm != 1) {\r
            DPRINT("# start search\n");\r
            LoadPos(moveNr); fflush(stdout); // load position\r
            // and set engine thinking (note USI swaps colors!)\r
@@ -438,6 +439,7 @@ LaunchSearch()
                EPRINT((f, "\n")) searching = 2; // suppresses spurious commands during analysis starting new searches\r
            } else searching = 3, StartSearch(""); // request suspending of input processing while thinking\r
        } else if(ponderAlways && computer == NONE) move[moveNr][0] = 0, StartPonder(moveNr-1);\r
+       else if(BLACK+WHITE-stm == computer && ponder && moveNr) StartPonder(moveNr);\r
 }\r
 \r
 void\r