X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=UCI2WB.c;h=178cdcb97e7c71b8cdd38df66a18b8a1cfcb4966;hb=8e699739bef4730a34efb65939800a3a3b6f13b0;hp=05600eee4f31f51589c585b51c749ae74aa17539;hpb=4c43c5722cf24b0cd44a9fe1f1eb6ad6c501d345;p=uci2wb.git diff --git a/UCI2WB.c b/UCI2WB.c index 05600ee..178cdcb 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -32,7 +32,7 @@ // Set VARIANTS for in WinBoard variant feature. (With -s option this will always be reset to use "shogi".) #define VARIANTS ",normal,xiangqi" #define STDVARS "chess,chess960,crazyhouse,3check,giveaway,suicide,losers,atomic,seirawan,shogi,xiangqi" -#define EGT ",gaviotaTbPath,syzygyPath,nalimovPath,robbotripleBaseDirectory,robbototalBaseDirectory," +#define EGT ",gaviotaTbPath,syzygyPath,nalimovPath,robbotripleBaseDirectory,robbototalBaseDirectory,bitbases path," #define DPRINT if(debug) printf #define EPRINT(X) { char f[999]; sprintf X; DPRINT("%s", f); fprintf(toE, "%s", f + 2*(*f == '#')); /* strip optional # prefix */ } @@ -48,7 +48,7 @@ int statDepth, statScore, statNodes, statTime, currNr, size, collect, nr, sm, in char currMove[20], moveMap[500][10], /* for analyze mode */ canPonder[20], threadOpt[20], varList[8000], anaOpt[20], backLog[10000], checkOptions[8192] = "Ponder"; char pvs[99][999], board[100]; // XQ board for UCCI char *nameWord = "name ", *valueWord = "value ", *wTime = "w", *bTime = "b", *wInc = "winc", *bInc = "binc", newGame; // keywords that differ in UCCI -int unit = 1, drawOffer, scores[99], mpvSP, maxDepth; +int unit = 1, drawOffer, scores[99], mpvSP, maxDepth, ponderAlways; volatile int logLen, sentLen; FILE *toE, *fromE, *fromF; @@ -185,7 +185,7 @@ LoadPos(int moveNr) } void -StartPonder() +StartPonder(int moveNr) { if(!move[moveNr][0]) return; // no ponder move LoadPos(moveNr+1); @@ -206,7 +206,7 @@ Release() if(len <= 0) return 0; StopPonder(pondering | searching); pondering = searching = 0; // force new search if settings change during analysis (multi-PV!) fwrite(backLog + sentLen, 1, len, toE); sentLen += len; DPRINT("# release %d\n", len); - if(ponder && computer == 1 - stm) StartPonder(); // (re)start ponder search + if(ponder && computer == 1 - stm) StartPonder(moveNr); // (re)start ponder search return analyse; // return 1 if analysis search should be restarted } @@ -287,7 +287,7 @@ Engine2GUI() sscanf(p+7, "%s", move[moveNr]); if(computer != NONE && ponder) { DPRINT("# ponder on %s\n", move[moveNr]); - StartPonder(); + StartPonder(moveNr); } p[-1] = '\n'; *p = 0; // strip off ponder move } else move[moveNr][0] = 0; @@ -302,7 +302,15 @@ Engine2GUI() char *pv, varName[80]; if(sscanf(line+5, "string times @ %c", &dummy) == 1) { printf("# %s", line+12); continue; } if(sscanf(line+5, "string variant %s", varName) == 1) { - if(!strstr(STDVARS, varName) && (p = strstr(line+18, " startpos "))) printf("setup (-) 8x8+0_fairy %s", p+10); + if(!strstr(STDVARS, varName)) { + int files = 8, ranks = 8, hand = 0; char parent[80]; + if(p = strstr(line+18, " files ")) sscanf(p+7, "%d", &files); + if(p = strstr(line+18, " ranks ")) sscanf(p+7, "%d", &ranks); + if(p = strstr(line+18, " pocket ")) sscanf(p+8, "%d", &hand); + if(p = strstr(line+18, " template ")) sscanf(p+10, "%s", parent); else strcpy(parent, "fairy"); + if(p = strstr(line+18, " startpos ")) + printf("setup (-) %dx%d+%d_%s %s", files, ranks, hand, parent, p+10); + } continue; } if(collect && (pv = strstr(line+5, "currmove "))) { @@ -361,7 +369,7 @@ Engine2GUI() if(!strcasecmp(name, "newgame") && !strcmp(type, "button")) { newGame++; continue; } if(!strcasecmp(name, "usemillisec")) { unit = (!strcmp(val, "false") ? 2 : 1); continue; } sprintf(buf, ",%s,", name); if(p = strcasestr(EGT, buf)) { // collect EGT formats - strcpy(buf, p); for(p=buf; *++p >='a';){} *p = 0; strcat(egts, buf); continue; // clip at first non-lower-case + strcpy(buf, p); for(p=buf; *++p >='a';){} if(*p == ' ') strcpy(buf, ",scorpio"); *p = 0; strcat(egts, buf); continue; // clip at first non-lower-case } // pass on engine-defined option as WB option feature if(!strcmp(type, "filename")) type[4] = 0; @@ -447,7 +455,7 @@ GUI2Engine() } EPRINT((f, "\n")) searching = 1; // suppresses spurious commands during analysis starting new searches } else pause = think = 2, StartSearch(""); // request suspending of input processing while thinking - } + } else if(ponderAlways && computer == NONE) move[moveNr][0] = 0, StartPonder(moveNr-1); nomove: for(difficult=0; !difficult; ) { // read and handle commands that can (or must) be handled during thinking fflush(toE); fflush(stdout); @@ -477,6 +485,7 @@ GUI2Engine() char *p; if(logLen == sentLen) logLen = 0, sentLen = 0; // engine is up to date; reset buffer if(sscanf(line+7, "UCI2WB debug output=%d", &debug) == 1) ; else + if(sscanf(line+7, "ponder always=%d", &ponderAlways) == 1) ; else if(sscanf(line+7, "Floating Byoyomi=%d", &flob) == 1) ; else if(sscanf(line+7, "Byoyomi=%d", &byo) == 1) ; else if(p = strchr(line, '=')) { @@ -511,7 +520,7 @@ GUI2Engine() continue; } if(!strcmp(command, "resume")) { - if(suspended == 2) StartPonder(); // restart interrupted ponder search + if(suspended == 2) StartPonder(moveNr); // restart interrupted ponder search suspended = think = 0; continue; // causes thinking to start in normal way if on move or analyzing } if(think) { // command arrived during thinking; order abort for 'instant commands' @@ -542,6 +551,7 @@ GUI2Engine() if(!varList[0]) strcpy(varList, sc=='s' ? ",shogi,5x5+5_shogi" : VARIANTS); printf("feature setboard=1 usermove=1 debug=1 ping=1 name=1 reuse=0 exclude=1 pause=1 sigint=0 sigterm=0 done=0\n"); printf("feature option=\"UCI2WB debug output -check %d\"\n", debug); + printf("feature option=\"ponder always -check %d\"\n", ponderAlways); if(sc == 's') printf("feature option=\"Floating Byoyomi -check %d\"\nfeature option=\"Byoyomi -spin %d -1 1000\"\n", flob, byo); EPRINT((f, sc == 'x' ? "# ucci\n" : "# u%ci\n", sc)) fflush(toE); // prompt UCI engine for options Sync(PAUSE); // wait for uciok @@ -593,7 +603,7 @@ GUI2Engine() else if(!strcmp(command, "cores")&& !!*threadOpt) { sscanf(line, "cores %d", &cores); EPRINT((f, "# setoption %s%s %s%d\n", nameWord, threadOpt, valueWord, cores)) } else if(!strcmp(command, "egtpath")){ sscanf(line+8, "%s %[^\n]", type, command); - if(p = strstr(EGT, type)) strcpy(type, p), p = strchr(type, ','), *p = 0; + if(p = strstr(EGT, type)) strcpy(type, p), p = strchr(type, ','), *p = 0; else strcpy(type, "bitbases path"); EPRINT((f, "# setoption name %s value %s\n", type, command)); } else if(!strcmp(command, "sd")) sscanf(line, "sd %d", &depth);