char line[256], command[256], *p;\r
\r
while(1) {\r
- int i, difficult, think=0;\r
+ int i, difficult;\r
\r
if((computer == stm || computer == ANALYZE && !searching) && !suspended) {\r
DPRINT("# start search\n");\r
for(i=1; i<nr; i++) if(on[i]) EPRINT((f, " %s", moveMap[i]))\r
}\r
EPRINT((f, "\n")) searching = 2; // suppresses spurious commands during analysis starting new searches\r
- } else pause = think = 2, StartSearch(""); // request suspending of input processing while thinking\r
+ } else pause = 2, searching = 3, StartSearch(""); // request suspending of input processing while thinking\r
} else if(ponderAlways && computer == NONE) move[moveNr][0] = 0, StartPonder(moveNr-1);\r
nomove:\r
for(difficult=0; !difficult; ) { // read and handle commands that can (or must) be handled during thinking\r
fflush(toE); fflush(stdout);\r
if(!ReadLine(stdin, line)) printf("# EOF\n"), sprintf(line, "quit -1\n");\r
- if(think && !pause) Sync(PAUSE), think = 0, Release(); // if no longer thinking, take dummy pause\r
- sscanf(line, "%s", command); DPRINT("# '%s' think=%d pause=%d log=%d sent=%d\n", command, think, pause, logLen, sentLen);\r
+ if(searching == 3 && !pause) Sync(PAUSE), searching = 0, Release(); // if no longer thinking, take dummy pause\r
+ sscanf(line, "%s", command); DPRINT("# '%s' searching=%d pause=%d log=%d sent=%d\n", command, searching, pause, logLen, sentLen);\r
if(!strcmp(command, "usermove")) { difficult--; break; } // for efficiency during game play, moves, time & otim are tried first\r
else if(!strcmp(command, "time")) sscanf(line+4, "%d", &myTime), myTime = (10*myTime)/unit;\r
else if(!strcmp(command, "otim")) sscanf(line+4, "%d", &hisTime), hisTime = (10*hisTime)/unit;\r
snprintf(backLog+logLen, 9999-logLen, "setoption %s%s %s%s", nameWord, line+7, valueWord, p);\r
} else snprintf(backLog+logLen, 9999-logLen, "setoption %s%s\n", nameWord, line+7);\r
DPRINT("# backlog: %s", backLog+logLen); logLen += strlen(backLog+logLen);\r
- if(!think && Release()) break; // break will restart analysis; pondering is restarted by Release itself\r
+ if(searching < 3 && Release()) break; // break will restart analysis; pondering is restarted by Release itself\r
}\r
else difficult = 1; // difficult command; terminate loop for easy ones\r
}\r
char *draw = drawOffer ? " draw" : ""; drawOffer = 0;\r
searching = 0; pause = 2; moveNr++; startTime = GetTickCount(); // clock starts running now\r
EPRINT((f, "# ponderhit%s\n", draw)) fflush(toE); fflush(stdout);\r
- think = 2; // request blocking input during thinking\r
+ searching = 3; // request blocking input during thinking\r
goto nomove;\r
}\r
StopPonder(1); searching = 0;\r
continue;\r
}\r
if(!strcmp(command, "resume")) {\r
+ searching = 0;\r
if(suspended == 2) StartPonder(moveNr); // restart interrupted ponder search\r
- suspended = think = 0; continue; // causes thinking to start in normal way if on move or analyzing\r
+ suspended = 0; continue; // causes thinking to start in normal way if on move or analyzing\r
}\r
- if(think) { // command arrived during thinking; order abort for 'instant commands'\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")) { EPRINT((f, "# stop\n")); fflush(toE); }\r
Sync(PAUSE); Release(); // block processing of difficult commands during thinking; send backlog left because of race\r