- strcpy(move[moveNr++], command); // possibly overwrites ponder move\r
- }\r
- else if(!strcmp(command, "level")) {\r
- int sec = 0;\r
- sscanf(line, "level %d %d:%d %d", &mps, &tc, &sec, &inc) == 4 ||\r
- sscanf(line, "level %d %d %d", &mps, &tc, &inc);\r
- tc = (60*tc + sec)*1000; inc *= 1000; sTime = 0; tc /= unit; inc /= unit;\r
+ } else\r
+ if(!strcmp(command, "resume")) {\r
+ if(suspended == 2) StartPonder(moveNr); // restart interrupted ponder search\r
+ suspended = 0; *qEnd++ = '\n'; Sync(WAKEUP); // causes search to start in normal way if on move or analyzing\r
+ } else\r
+ {\r
+ DPRINT("# queue '%s', searching=%d\n", command, searching);\r
+ if(searching == 3) { // command arrived during thinking; order abort for 'instant commands'\r
+ if(!strcmp(command, "?") || !strcmp(command, "quit") ||\r
+ !strcmp(command, "force") || !strcmp(command, "result")) StopSearch(0);\r
+ } else StopSearch(1); // always abort pondering or analysis\r
+\r
+ // queue command for execution by engine thread\r
+ if(qStart == qEnd) qStart = qEnd = queue;\r
+ p = line; while(qEnd < queue+10000 && (*qEnd++ = *p++) != '\n') {}\r
+ Sync(WAKEUP);\r
+ // when 'stop' doesn't catch engine's attention in reasonable time, so the GUI might kill us:\r
+ if(!strcmp(command, "quit")) { Bury(killDelay); exit(0); } // kill the engine and exit\r
+ }\r
+ }\r
+}\r
+\r
+void\r
+IsReady ()\r
+{\r
+ EPRINT((f, "# isready\n")) fflush(toE);\r
+ HandleEngineOutput(); // wait for readyok\r
+}\r
+\r
+void\r
+DoCommand ()\r
+{\r
+ char line[1024], command[256], *p, *q, *r, type[99], c;\r
+ int i;\r
+\r
+ p=line; while(qStart < qEnd && (*p++ = *qStart++) != '\n') {} *p = 0;\r
+ sscanf(line, "%s %s", command, type); DPRINT("# command %s\n", command), fflush(stdout);\r
+\r
+ if(!strcmp(command, "new")) {\r
+ computer = BLACK; moveNr = 0; depth = -1; move[0][0] = 0;\r
+ stm = WHITE; strcpy(iniPos, "position startpos"); frc &= ~1;\r
+ if(newCnt++) return; // prevent a 2nd 'isready' due to reuse=0-violating 'new' preceding 'quit'\r
+ 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(varOpt && strstr(varList, ",normal")) EPRINT((f, "# setoption name UCI_Variant value chess\n"))\r
+ IsReady();\r
+ if(sc == 'x') { if(newGame) EPRINT((f, "# setoption newgame\n")) } else // optional in UCCI\r
+ { EPRINT((f, "# u%cinewgame\n", sc)) fflush(toE); if(sc != 's') IsReady(); } // avoid isready in USI\r