X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=UCI2WB.c;h=dffac3b37098030c560d70cdb657431600f2371d;hb=05c7d739a244a923c0f3e90bcb10f3db9f5e670c;hp=37f9de63b5418cea2f073e62621e2a9a37df405a;hpb=be5b48e447abc318aa999ad07198ba2da3fff41f;p=uci2wb.git diff --git a/UCI2WB.c b/UCI2WB.c index 37f9de6..dffac3b 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -9,7 +9,7 @@ /* of which you should have received a copy together with this file. */ /****************************************************************************/ -#define VERSION "2.2" +#define VERSION "2.3" #include #include @@ -30,7 +30,8 @@ #include // Set VARIANTS for in WinBoard variant feature. (With -s option this will always be reset to use "shogi".) -# define VARIANTS "normal,xiangqi" +#define VARIANTS "normal,xiangqi" +#define STDVARS "chess,chess960,crazyhouse,threecheck,giveaway,atomic,seirawan,shogi,xiangqi" #define DPRINT if(debug) printf @@ -41,7 +42,7 @@ char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, pondering, suspended, ponder, post, hasHash, c, sc='c', suffix[81], *variants, varOpt; int mps, tc, inc, sTime, depth, myTime, hisTime, stm, computer = NONE, memory, oldMem=0, cores, moveNr, lastDepth, lastScore, startTime, debug, flob; -int statDepth, statScore, statNodes, statTime, currNr, size, collect, nr, sm, inex, on[500], frc, byo = -1; +int statDepth, statScore, statNodes, statTime, currNr, size, collect, nr, sm, inex, on[500], frc, byo = -1, namOpt, comp; char currMove[20], moveMap[500][10], /* for analyze mode */ canPonder[20], threadOpt[20], varList[8000]; char 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 @@ -51,6 +52,8 @@ FILE *toE, *fromE, *fromF; int pid; #ifdef WIN32 +char *strcasestr (char *p, char *q) { char *r = p; while(*r) *r = tolower(*r), r++; return strstr(p, q); } + WinPipe(HANDLE *hRd, HANDLE *hWr) { SECURITY_ATTRIBUTES saAttr; @@ -276,8 +279,12 @@ Engine2GUI() } else if(!strcmp(command, "info")) { int d=0, s=0, t=(GetTickCount() - startTime)/10, n=1; - char *pv; + 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); + continue; + } if(collect && (pv = strstr(line+5, "currmove "))) { if(p = strstr(line+5, "currmovenumber ")) { n = atoi(p+15); @@ -313,6 +320,7 @@ Engine2GUI() if(!(p = strstr(line+6, " name "))) p = line+1; sscanf(p+6, "%[^\n]", name); // 'name' is omitted in UCCI if(!strcasecmp(name, "UCI_Chess960")) { frc=2; continue; } if(!strcasecmp(name, "UCI_Variant")) { if(p = strstr(line+6, " var ")) strcpy(varList, p); varOpt = 1; continue; } + if(!strcasecmp(name, "UCI_Opponent")) { namOpt = 1; continue; } if(frc< 0 && (strstr(name, "960") || strcasestr(name, "frc")) && !strcmp(type, "check")) { fprintf(toE, "setoption name %s value true\n", name); strcpy(val, "true"); // set non-standard suspected FRC options } @@ -387,12 +395,12 @@ Move4Engine(char *m) void GUI2Engine() { - char line[256], command[256], *p, *q, *r, mySide; + char line[256], command[256], *p, *q, *r, mySide, searching = 0; while(1) { int i, x; - if((computer == stm || computer == ANALYZE) && !suspended) { + if((computer == stm || computer == ANALYZE && !searching) && !suspended) { DPRINT("# start search\n"); LoadPos(moveNr); fflush(stdout); // load position // and set engine thinking (note USI swaps colors!) @@ -403,8 +411,7 @@ GUI2Engine() fprintf(toE, " searchmoves"); DPRINT(" searchmoves"); for(i=1; i 0) fprintf(toE, "setoption name UCI_Chess960 value true\n"); } } else if(!strcmp(command, "undo") && (i=1) || !strcmp(command, "remove") && (i=2)) { - if(pondering || computer == ANALYZE) StopPonder(1); + if(pondering || computer == ANALYZE) StopPonder(1), searching = 0; moveNr = moveNr > i ? moveNr - i : 0; collect = (computer == ANALYZE); sm = 0; } else if(!strcmp(command, ".")) { @@ -499,7 +510,7 @@ GUI2Engine() inex = 1; line[strlen(line)-1] = sm = 0; // strip LF and clear sm flag for(i=1; i