\r
char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, pondering, ponder, post, hasHash, c, sc='c', *suffix, *variants;\r
int mps, tc, inc, sTime, depth, myTime, hisTime, stm, computer = NONE, memory, oldMem=0, cores, moveNr, lastDepth, lastScore, startTime, debug;\r
-int statDepth, statScore, statNodes, statTime, currNr, size; char currMove[20]; // for analyze mode\r
+int statDepth, statScore, statNodes, statTime, currNr, size, collect, nr, sm, on[500]; char currMove[20], moveMap[500][10]; // for analyze mode\r
\r
FILE *toE, *fromE;\r
int pid;\r
int d=0, s=0, t=0, n=0;\r
char *pv;\r
if(sscanf(line+5, "string times @ %c", &dummy) == 1) { printf("# %s", line+12); continue; }\r
+ if(collect && (pv = strstr(line+5, "currmove "))) {\r
+ if(p = strstr(line+5, "currmovenumber ")) {\r
+ n = atoi(p+15);\r
+ if(collect == 1 && n != 1) continue; // wait for move 1\r
+ if(collect + (n == 1) > 2) { collect = 3; continue; } // done collecting\r
+ collect = 2; on[nr=n] = 1; sscanf(pv+9, "%s", moveMap[n]); continue; // store move\r
+ }\r
+ }\r
if(!post) continue;\r
if(sscanf(line+5, "string %c", &dummy) == 1) printf("%d 0 0 0 %s", lastDepth, line+12); else {\r
if(p = strstr(line+4, " depth ")) sscanf(p+7, "%d", &d), statDepth = d;\r
LoadPos(moveNr); // load position\r
// and set engine thinking (note USI swaps colors!)\r
startTime = GetTickCount();\r
- if(computer == ANALYZE) fprintf(toE, "\ngo infinite\n"), printf("\ngo infinite\n");\r
- else StartSearch("");\r
+ if(computer == ANALYZE) {\r
+ fprintf(toE, "\ngo infinite"); DPRINT("\n# go infinite");\r
+ if(sm & 1) { // some moves are disabled\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
+ } else StartSearch("");\r
}\r
nomove:\r
fflush(toE); fflush(stdout);\r
else if(!strcmp(command, "usermove")) {\r
sscanf(line, "usermove %s", command); // strips off linefeed\r
Move4Engine(command);\r
- stm = WHITE+BLACK - stm;\r
+ stm = WHITE+BLACK - stm; collect = (computer == ANALYZE); sm = 0;\r
// when pondering we either continue the ponder search as normal search, or abort it\r
if(pondering || computer == ANALYZE) {\r
if(pondering && !strcmp(command, move[moveNr])) { // ponder hit\r
}\r
else if(!strcmp(command, "protover")) {\r
if(!variants) variants = sc=='s' ? "shogi,5x5+5_shogi" : VARIANTS;\r
- printf("feature variants=\"%s\" setboard=1 usermove=1 debug=1 ping=1 reuse=0 done=0\n", variants);\r
+ printf("feature variants=\"%s\" setboard=1 usermove=1 debug=1 ping=1 reuse=0 exclude=1 done=0\n", variants);\r
printf("feature option=\"UCI2WB debug output -check %d\"\n", debug);\r
fprintf(toE, "u%ci\n", sc); fflush(toE); // this prompts UCI engine for options\r
Sync(PAUSE); // wait for uciok\r
*r = 0; sprintf(command, "%s%s %s %s", line+9, q+1, p, r+1);\r
} else strcpy(command, line+9);\r
sprintf(iniPos, "%s%sfen %s", iniPos[0]=='p' ? "position " : "", sc=='s' ? "s" : "", command);\r
- iniPos[strlen(iniPos)-1] = 0;\r
+ iniPos[strlen(iniPos)-1] = sm = 0; collect = (computer == ANALYZE);\r
}\r
else if(!strcmp(command, "variant")) {\r
if(!strcmp(line+8, "shogi\n")) size = 9, strcpy(iniPos, "position startpos");\r
}\r
else if(!strcmp(command, "undo") && (i=1) || !strcmp(command, "remove") && (i=2)) {\r
if(pondering || computer == ANALYZE) StopPonder(1);\r
- moveNr = moveNr > i ? moveNr - i : 0;\r
+ moveNr = moveNr > i ? moveNr - i : 0; collect = (computer == ANALYZE); sm = 0;\r
}\r
else if(!strcmp(command, ".")) {\r
printf("stat01: %d %d %d %d 100 %s\n", statTime, statNodes, statDepth, 100-currNr, currMove);\r
goto nomove;\r
}\r
+ else if(!strcmp(command+2, "clude") && collect > 2) {\r
+ int all = !strcmp(line+8, "all"), in = command[1] == 'n';\r
+ 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
+ }\r
else if(!strcmp(command, "xboard")) ;\r
- else if(!strcmp(command, "analyze"))computer = ANALYZE;\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, "force")) computer = NONE, StopPonder(pondering);\r
else if(!strcmp(command, "go")) computer = stm;\r