X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=UCI2WB.c;h=029b34b133e9abee2e1f3f6fe160d18469edaeb6;hb=f9dc502ea66938564e9e6eabcc2aff4199f5dd83;hp=71dfd4b5e920dfe73ead029b853fbb18e740d01e;hpb=f72070254816c26ab9e52862e6191b2a59029e4d;p=uci2wb.git diff --git a/UCI2WB.c b/UCI2WB.c index 71dfd4b..029b34b 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -1,6 +1,6 @@ /************************* UCI2WB by H.G.Muller ****************************/ -#define VERSION "1.8" +#define VERSION "1.10" #include #include @@ -30,9 +30,9 @@ #define NONE 2 #define ANALYZE 3 -char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, pondering, ponder, post, hasHash, c, sc='c', *suffix, *variants; +char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, pondering, suspended, ponder, post, hasHash, c, sc='c', *suffix, *variants; int mps, tc, inc, sTime, depth, myTime, hisTime, stm, computer = NONE, memory, oldMem=0, cores, moveNr, lastDepth, lastScore, startTime, debug; -int statDepth, statScore, statNodes, statTime, currNr, size, collect, nr, sm, on[500]; char currMove[20], moveMap[500][10]; // for analyze mode +int statDepth, statScore, statNodes, statTime, currNr, size, collect, nr, sm, inex, on[500]; char currMove[20], moveMap[500][10]; // for analyze mode FILE *toE, *fromE; int pid; @@ -79,9 +79,10 @@ Sync (int action) void StartSearch(char *ponder) { // send the 'go' command to engine. Suffix by ponder. - int nr = moveNr + (ponder[0] != 0); // we ponder for one move ahead! - fprintf(toE, "\ngo btime %d wtime %d", stm == BLACK ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ sc=='s' ? myTime : hisTime); - DPRINT( "\n# go btime %d wtime %d", stm == BLACK ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ sc=='s' ? myTime : hisTime); + int x = (ponder[0] != 0); + int nr = moveNr + x; // we ponder for one move ahead! + fprintf(toE, "\ngo btime %d wtime %d", stm == BLACK ^ x ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ x ^ sc=='s' ? myTime : hisTime); + DPRINT( "\n# go btime %d wtime %d", stm == BLACK ^ x ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ x ^ sc=='s' ? myTime : hisTime); 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(inc && !suffix) { fprintf(toE, " winc %d binc %d", inc, inc); DPRINT(" winc %d binc %d", inc, inc); } @@ -109,6 +110,15 @@ LoadPos(int moveNr) for(j=0; j 2) { collect = 3; continue; } // done collecting + if(collect + (n == 1) > 2) { // done collecting + if(inex && collect == 2) printf("%d 0 0 0 OK to exclude\n", lastDepth); + collect = 3; continue; + } collect = 2; on[nr=n] = 1; sscanf(pv+9, "%s", moveMap[n]); continue; // store move } } @@ -265,12 +273,7 @@ Move4Engine(char *m) m[2] = 'a'+'0'+size - m[2]; m[3] = 'a'+'0'+size - m[3]; if(m[4] == '=') m[4] = 0; // no '=' in USI format! - else if(m[4] != '\n') m[4] = '+'; // cater to WB 4.4 bug :-( - } - if(m[4] && (m[1] == '1' || m[1] == '8')) { // seirawan gating - m[5] = m[0], m[6] = m[1], m[7] = '\0'; // copy from-square behind it, as gating square - if(m[2] == 'e' && (m[0] == 'a' || m[0] == 'h')) - m[2] = (m[0]+m[2]+1)>>1, m[0] = 'e'; // gating at Rook + else if(m[4]) m[4] = '+'; // cater to WB 4.4 bug :-( } } @@ -282,7 +285,7 @@ GUI2Engine() while(1) { int i, x; - if(computer == stm || computer == ANALYZE) { + if((computer == stm || computer == ANALYZE) && !suspended) { DPRINT("# start search\n"); LoadPos(moveNr); // load position // and set engine thinking (note USI swaps colors!) @@ -303,7 +306,7 @@ GUI2Engine() line[++i] = 0; if(x == EOF) { printf("# EOF\n"); exit(-1); } sscanf(line, "%s", command); if(!strcmp(command, "new")) { - computer = BLACK; moveNr = 0; depth = -1; + computer = BLACK; moveNr = 0; depth = -1; move[0][0] = 0; stm = WHITE; strcpy(iniPos, "position startpos"); if(memory != oldMem && hasHash) fprintf(toE, "setoption name %s value %d\n", hashOpt, memory); oldMem = memory; @@ -345,7 +348,7 @@ GUI2Engine() } else if(!strcmp(command, "protover")) { 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 done=0\n", variants); + printf("feature variants=\"%s\" setboard=1 usermove=1 debug=1 ping=1 reuse=0 exclude=1 pause=1 done=0\n", variants); printf("feature option=\"UCI2WB debug output -check %d\"\n", debug); fprintf(toE, "u%ci\n", sc); fflush(toE); // this prompts UCI engine for options Sync(PAUSE); // wait for uciok @@ -374,13 +377,21 @@ GUI2Engine() printf("stat01: %d %d %d %d 100 %s\n", statTime, statNodes, statDepth, 100-currNr, currMove); goto nomove; } - else if(!strcmp(command+2, "clude") && collect > 2) { + else if(!strcmp(command+2, "clude") && collect > 2) { // include or exclude int all = !strcmp(line+8, "all"), in = command[1] == 'n'; - line[strlen(line)-1] = sm = 0; // strip LF and clear sm flag + inex = 1; line[strlen(line)-1] = sm = 0; // strip LF and clear sm flag for(i=1; i