X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=blobdiff_plain;f=UCI2WB.c;h=ff5ec8cdfb142053da5a38a346c25fb35b47d3d9;hp=781f8f5bc1912d6bf41f769471672557f29efb39;hb=7bd5b32b970229a4a9cc23ca2e8849e30c6d9823;hpb=4ab8d7efe96ed40e3ae2abf2ef5e55379888cfde diff --git a/UCI2WB.c b/UCI2WB.c index 781f8f5..ff5ec8c 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.0" +#define VERSION "2.1" #include #include @@ -141,13 +141,14 @@ StartSearch(char *ponder) int x = (ponder[0] != 0); // during ponder stm is the opponent int black = (stm == BLACK ^ x ^ sc == 's'); // set if our color is what the engine calls black int nr = moveNr + x; // we ponder for one move ahead! + int t = (flob ? inc + myTime/40 : 1000*byo*(byo>0)); // byoyomi time if(sc == 'x') black = 1; else drawOffer = 0;// in UCCI 'black' refers to us and 'white' to opponent if(!x && drawOffer) ponder = " draw", drawOffer = 0; //pass draw offer only when not pondering - fprintf(toE, "\ngo%s %stime %d %stime %d", ponder, bTime, black ? myTime : hisTime, wTime, !black ? myTime : hisTime); - DPRINT( "\n# go%s %stime %d %stime %d", ponder, bTime, black ? myTime : hisTime, wTime, !black ? myTime : hisTime); + fprintf(toE, "\ngo%s %stime %d %stime %d", ponder, bTime, (black ? myTime : hisTime) - t, wTime, (!black ? myTime : hisTime) - t); + DPRINT( "\n# go%s %stime %d %stime %d", ponder, bTime, (black ? myTime : hisTime) - t, wTime, (!black ? myTime : hisTime) - t); if(sTime > 0) { fprintf(toE, " movetime %d", sTime); DPRINT(" movetime %d", sTime); } else if(mps) { fprintf(toE, " movestogo %d", mps*(nr/(2*mps)+1)-nr/2); DPRINT(" movestogo %d", mps*(nr/(2*mps)+1)-nr/2); } - if(flob || byo >= 0) sprintf(suffix, " byoyomi %d", byo >=0 ? 1000*byo : inc + myTime/40); // for engines running purely on byoyomi + if(flob || byo >= 0) sprintf(suffix, " byoyomi %d", t); // for engines running purely on byoyomi if(inc && !*suffix) { fprintf(toE, " %s %d %s %d", wInc, inc, bInc, inc); DPRINT(" %s %d %s %d", wInc, inc, bInc, inc); } if(depth > 0) { fprintf(toE, " depth %d", depth); DPRINT(" depth %d", depth); } if(*suffix) { fprintf(toE, suffix, inc); DPRINT(suffix, inc); } @@ -251,6 +252,7 @@ Engine2GUI() // move was a move to be played if(p = strstr(line+8, " draw")) *p = 0, printf("offer draw\n"); // UCCI if(strstr(line+9, "resign")) { printf("resign\n"); computer = NONE; } + if(strstr(line+9, "win")) { printf("%s {claim}\n", stm== WHITE ? "1-0" :"0-1"); computer = NONE; } // USI if(strstr(line+9, "(none)") || strstr(line+9, "null") || strstr(line+9, "0000")) { printf("%s\n", lastScore < -99999 ? "resign" : "1/2-1/2 {stalemate}"); computer = NONE; } sscanf(line, "bestmove %s", move[moveNr++]); @@ -378,7 +380,7 @@ Move4Engine(char *m) void GUI2Engine() { - char line[256], command[256], *p, *q, *r; + char line[256], command[256], *p, *q, *r, mySide; while(1) { int i, x; @@ -387,7 +389,7 @@ GUI2Engine() DPRINT("# start search\n"); LoadPos(moveNr); fflush(stdout); // load position // and set engine thinking (note USI swaps colors!) - startTime = GetTickCount(); + startTime = GetTickCount(); mySide = stm; // remember side we last played for if(computer == ANALYZE) { fprintf(toE, "\ngo infinite"); DPRINT("\n# go infinite"); if(sm & 1) { // some moves are disabled @@ -453,7 +455,7 @@ GUI2Engine() if(!variants) variants = sc=='s' ? "shogi,5x5+5_shogi" : VARIANTS; printf("feature variants=\"%s\" setboard=1 usermove=1 debug=1 ping=1 reuse=0 exclude=1 pause=1 sigint=0 sigterm=0 done=0\n", variants); printf("feature option=\"UCI2WB debug output -check %d\"\n", debug); - if(sc == 's') printf("feature option=\"Floating Byoyomi -check %d\" option=\"Byoyomi -spin %d -1 1000\"\n", flob, byo); + if(sc == 's') printf("feature option=\"Floating Byoyomi -check %d\"\nfeature option=\"Byoyomi -spin %d -1 1000\"\n", flob, byo); fprintf(toE, sc == 'x' ? "ucci\n" : "u%ci\n", sc); fflush(toE); // prompt UCI engine for options Sync(PAUSE); // wait for uciok } @@ -516,6 +518,7 @@ GUI2Engine() else if(!strcmp(command, "sd")) sscanf(line, "sd %d", &depth); else if(!strcmp(command, "st")) sscanf(line, "st %d", &sTime), sTime = 1000*sTime - 30, inc = 0, sTime /= unit; else if(!strcmp(command, "offer")) drawOffer = 1; + else if(!strcmp(command, "result")) { if(sc == 's') fprintf(toE, "gameover %s\n", line[8] == '/' ? "draw" : (line[7] == '0') == mySide ? "win" : "lose"); } else if(!strcmp(command, "quit")) fprintf(toE, "quit\n"), fflush(toE), exit(0); } }