char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, pondering, suspended, ponder, post, hasHash, c, sc='c', suffix[81], *variants, varOpt;\r
int mps, tc, inc, sTime, depth, myTime, hisTime, stm, computer = NONE, memory, oldMem=0, cores, moveNr, lastDepth, lastScore, startTime, debug, flob;\r
int statDepth, statScore, statNodes, statTime, currNr, size, collect, nr, sm, inex, on[500], frc, byo = -1, namOpt, comp;\r
-char currMove[20], moveMap[500][10], /* for analyze mode */ canPonder[20], threadOpt[20], varList[8000];\r
+char currMove[20], moveMap[500][10], /* for analyze mode */ canPonder[20], threadOpt[20], varList[8000], anaOpt[20];\r
char board[100]; // XQ board for UCCI\r
char *nameWord = "name ", *valueWord = "value ", *wTime = "w", *bTime = "b", *wInc = "winc", *bInc = "binc", newGame; // keywords that differ in UCCI\r
int unit = 1, drawOffer;\r
StartSearch(" ponder");\r
}\r
\r
+void\r
+Analyze(char *val)\r
+{\r
+ if(*anaOpt) EPRINT((f, "# setoption %s%s %s%s\n", nameWord, anaOpt, valueWord, val));\r
+}\r
+\r
char *Convert(char *pv)\r
{ // convert Shogi coordinates to WB\r
char *p, *q, c;\r
if(!strcasecmp(name, "UCI_Chess960")) { frc=2; continue; }\r
if(!strcasecmp(name, "UCI_Variant")) { if(p = strstr(line+6, " var ")) strcpy(varList, p); varOpt = 1; continue; }\r
if(!strcasecmp(name, "UCI_Opponent")) { namOpt = 1; continue; }\r
+ if(!strcasecmp(name+2, "I_AnalyseMode")) { strcpy(anaOpt, name); continue; }\r
if(frc< 0 && (strstr(name, "960") || strcasestr(name, "frc")) && !strcmp(type, "check")) {\r
EPRINT((f, "# setoption name %s value true\n", name)) strcpy(val, "true"); // set non-standard suspected FRC options\r
}\r
char line[256], command[256], *p, *q, *r, mySide, searching = 0;\r
\r
while(1) {\r
- int i, x;\r
+ int i, x, think=0;\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 = 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
+ } else pause = think = 2, StartSearch(""); // request suspending of input processing while thinking\r
}\r
nomove:\r
fflush(toE); fflush(stdout);\r
i = 0; while((x = getchar()) != EOF && (line[i] = x) != '\n') i++;\r
- line[++i] = 0; if(x == EOF) { printf("# EOF\n"); EPRINT((f, "# quit\n")) exit(-1); }\r
+ line[++i] = 0; if(x == EOF) { printf("# EOF\n"); sprintf(line, "quit -1\n"); }\r
sscanf(line, "%s", command);\r
+ if(!strcmp(command, "offer")) { drawOffer = 1; goto nomove; } // backlogged anyway, so this can be done instantly\r
+ if(think) { // 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); // block processing of input during thinking\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
suspended = 0; // causes thinking to start in normal way if on move or analyzing\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), searching = 0;\r
+ else if(!strcmp(command, "analyze"))computer = ANALYZE, collect = 1, sm = 0, Analyze("true");\r
+ else if(!strcmp(command, "exit")) computer = NONE, StopPonder(1), searching = 0, Analyze("false");\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
else if(!strcmp(command, "st")) sscanf(line, "st %d", &sTime), sTime = 1000*sTime - 30, inc = 0, sTime /= unit;\r
else if(!strcmp(command, "name")) { if(namOpt) EPRINT((f, "# setoption name UCI_Opponent value none none %s %s", comp ? "computer" : "human", line+5)) }\r
else if(!strcmp(command, "computer")) comp = 1;\r
- else if(!strcmp(command, "offer")) drawOffer = 1;\r
- else if(!strcmp(command, "result")) { if(sc == 's') EPRINT((f, "# gameover %s\n", line[8] == '/' ? "draw" : (line[7] == '0') == mySide ? "win" : "lose")) }\r
- else if(!strcmp(command, "quit")) { EPRINT((f, "# quit\n")) fflush(toE), exit(0); }\r
+ else if(!strcmp(command, "result")) {\r
+ if(sc == 's') EPRINT((f, "# gameover %s\n", line[8] == '/' ? "draw" : (line[7] == '0') == mySide ? "win" : "lose"))\r
+ computer = NONE;\r
+ }\r
+ else if(!strcmp(command, "quit")) { EPRINT((f, "# quit\n")) fflush(toE), exit(atoi(line+4)); }\r
}\r
}\r
\r