void\r
GUI2Engine()\r
{\r
- char line[256], command[256], *p, *q, *r, mySide;\r
+ char line[256], command[256], *p, *q, *r, mySide, searching = 0;\r
\r
while(1) {\r
int i, x;\r
\r
- if((computer == stm || computer == ANALYZE) && !suspended) {\r
+ if((computer == stm || computer == ANALYZE && !searching) && !suspended) {\r
DPRINT("# start search\n");\r
LoadPos(moveNr); fflush(stdout); // load position\r
// and set engine thinking (note USI swaps colors!)\r
fprintf(toE, " searchmoves"); DPRINT(" searchmoves");\r
for(i=1; i<nr; i++) if(on[i]) { fprintf(toE, " %s", moveMap[i]); DPRINT(" %s", moveMap[i]); }\r
}\r
- fprintf(toE, "\n"); DPRINT("\n");\r
- // code for searchmoves goes here\r
+ fprintf(toE, "\n"); DPRINT("\n"); searching = 1; // suppresses spurious commands during analysis starting new searches\r
} else { pause = 2; StartSearch(""); fflush(stdout); fflush(toE); Sync(PAUSE); } // block input during thinking\r
}\r
nomove:\r
Sync(PAUSE); // block input during thinking\r
goto nomove;\r
}\r
- StopPonder(1);\r
+ StopPonder(1); searching = 0;\r
}\r
strcpy(move[moveNr++], command); // possibly overwrites ponder move\r
}\r
}\r
else if(!strcmp(command, "option")) {\r
char name[80], *p;\r
+ if(searching) StopPonder(1), searching = 0; // force new search if settings change during analysis (multi-PV!)\r
if(sscanf(line+7, "UCI2WB debug output=%d", &debug) == 1) ; else\r
if(sscanf(line+7, "Floating Byoyomi=%d", &flob) == 1) ; else\r
if(sscanf(line+7, "Byoyomi=%d", &byo) == 1) ; else\r
if(!strcmp(line+8, "fischerandom\n")) { frc |= 1; if(frc > 0) fprintf(toE, "setoption name UCI_Chess960 value true\n"); }\r
}\r
else if(!strcmp(command, "undo") && (i=1) || !strcmp(command, "remove") && (i=2)) {\r
- if(pondering || computer == ANALYZE) StopPonder(1);\r
+ if(pondering || computer == ANALYZE) StopPonder(1), searching = 0;\r
moveNr = moveNr > i ? moveNr - i : 0; collect = (computer == ANALYZE); sm = 0;\r
}\r
else if(!strcmp(command, ".")) {\r
inex = 1; line[strlen(line)-1] = sm = 0; // strip LF and clear sm flag\r
for(i=1; i<nr; i++) { if(!strcmp(line+8, moveMap[i]) || all) on[i] = in; sm |= on[i]+1; } // sm: 2 = enabled, 1 = disabled\r
if(!(sm & 2)) goto nomove; // no moves enabled; continue current search\r
- if(computer == ANALYZE) StopPonder(1); // abort old analysis\r
+ if(computer == ANALYZE) StopPonder(1), searching = 0; // abort old analysis\r
}\r
else if(!strcmp(command, "pause")) {\r
if(computer == stm) myTime -= GetTickCount() - startTime;\r
}\r
else if(!strcmp(command, "xboard")) ;\r
else if(!strcmp(command, "analyze"))computer = ANALYZE, collect = 1, sm = 0;\r
- else if(!strcmp(command, "exit")) computer = NONE, StopPonder(1);\r
+ else if(!strcmp(command, "exit")) computer = NONE, StopPonder(1), searching = 0;\r
else if(!strcmp(command, "force")) computer = NONE, StopPonder(pondering);\r
else if(!strcmp(command, "go")) computer = stm;\r
else if(!strcmp(command, "time")) sscanf(line+4, "%d", &myTime), myTime = (10*myTime)/unit;\r