X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=blobdiff_plain;f=UCI2WB.c;h=7cdf340c0a63cd8c597b01260388d11f602233c5;hp=1cb0a1656b06c9d06064fd3377e2047176a8d966;hb=HEAD;hpb=8d90214e278c27dbf72b24383ac9e3ad24d54a27 diff --git a/UCI2WB.c b/UCI2WB.c index 1cb0a16..7cdf340 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 "3.0" +#define VERSION "4.0" #include #include @@ -188,6 +188,7 @@ StartPonder(int moveNr) if(!move[moveNr][0]) return; // no ponder move LoadPos(moveNr+1); searching = 1; lastDepth = 1; + DPRINT("# ponder on %s\n", move[moveNr]); StartSearch(" ponder"); } @@ -266,10 +267,7 @@ HandleEngineOutput() // first start a new ponder search, if pondering is on and we have a move to ponder on if(p = strstr(line+9, "ponder")) { sscanf(p+7, "%s", move[moveNr]); - if(computer != NONE && ponder) { - DPRINT("# ponder on %s\n", move[moveNr]); - StartPonder(moveNr); - } + if(computer != NONE && ponder) StartPonder(moveNr); p[-1] = '\n'; *p = 0; // strip off ponder move } else move[moveNr][0] = 0; Move4GUI(line+9); @@ -294,17 +292,6 @@ HandleEngineOutput() } continue; } - if(collect && (pv = strstr(line+5, "currmove "))) { - if(p = strstr(line+5, "currmovenumber ")) { - n = atoi(p+15); - if(collect == 1 && n != 1) continue; // wait for move 1 - 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 - } - } if(!post) continue; if(sscanf(line+5, "string %c", &dummy) == 1) printf("%d 0 0 0 %s", lastDepth, line+12); else { if(p = strstr(line+4, " depth ")) sscanf(p+7, "%d", &d), statDepth = d; @@ -313,8 +300,6 @@ HandleEngineOutput() if(p = strstr(line+4, " score ")) sscanf(p+7, "%d", &s), statScore = s; if(p = strstr(line+4, " nodes ")) sscanf(p+7, "%d", &n), statNodes = n; if(p = strstr(line+4, " time ")) sscanf(p+6, "%d", &t), t /= 10, statTime = t; - if(p = strstr(line+4, " currmove ")) sscanf(p+10,"%s", currMove); - if(p = strstr(line+4, " currmovenumber ")) sscanf(p+16,"%d", &currNr); if(pv = strstr(line+4, " pv ")) { // convert PV info to WB thinking output if(d > maxDepth) maxDepth = d, mpvSP = 0; else if(d < maxDepth) continue; // ignore depth regressions if(p = strstr(line+4, " upperbound ")) strcat(p, "?\n"); else @@ -324,6 +309,18 @@ HandleEngineOutput() printf("%3d %6d %6d %10d %s", lastDepth=d, lastScore=s, t, n, Convert(pv+4)); } else if(s == -100000) lastScore = s; // when checkmated score is valid even without PV (which might not come) } + if(collect && (pv = strstr(line+4, " currmove "))) { + sscanf(pv+10,"%s", currMove); + if(p = strstr(line+4, " currmovenumber ")) { + n = currNr = atoi(p+16); + if(collect == 1 && n != 1) continue; // wait for move 1 + 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; strcpy(moveMap[n], currMove); continue; // store move + } + } } else if(!strcmp(command, "option")) { // USI option: extract data fields char name[80], type[80], buf[1024], val[256], *q; @@ -372,6 +369,7 @@ HandleEngineOutput() sprintf(buf + strlen(buf), "%s%s%s", min++ ? " /// " : " ", strcmp(type, val) ? "" : "*", val); } strcat(q, "\"\n"); + } else buf[0] = 0; // ignore unrecognized option types if(buf[0]) printf("%s", buf); @@ -425,7 +423,9 @@ LaunchSearch() { int i; - if((computer == stm || computer == ANALYZE && !searching && sm != 1) && !suspended) { + if(suspended || searching) return; + + if(computer == stm || computer == ANALYZE && sm != 1) { DPRINT("# start search\n"); LoadPos(moveNr); fflush(stdout); // load position // and set engine thinking (note USI swaps colors!) @@ -439,6 +439,7 @@ LaunchSearch() EPRINT((f, "\n")) searching = 2; // suppresses spurious commands during analysis starting new searches } else searching = 3, StartSearch(""); // request suspending of input processing while thinking } else if(ponderAlways && computer == NONE) move[moveNr][0] = 0, StartPonder(moveNr-1); + else if(BLACK+WHITE-stm == computer && ponder && moveNr) StartPonder(moveNr); } void @@ -460,7 +461,7 @@ GUI2Engine() else if(!strcmp(command, "post")) post = 1; else if(!strcmp(command, "nopost"))post = 0; else if(!strcmp(command, ".")) { - printf("stat01: %d %d %d %d 100 %s\n", statTime, statNodes, statDepth, 100-currNr, currMove); + printf("stat01: %d %d %d %d %d %s\n", statTime, statNodes, statDepth, nr-currNr, nr, currMove); } else if(!strcmp(command, "pause")) { if(computer == stm) myTime -= GetTickCount() - startTime; @@ -468,8 +469,12 @@ GUI2Engine() StopSearch(1); } else if(!strcmp(command, "xboard")) ; + else if(!strcmp(command, "random")) ; else if(!strcmp(command, "accepted")) ; else if(!strcmp(command, "rejected")) ; + else if(!strcmp(command, "book")) ; + else if(!strcmp(command, "ics")) ; + else if(!strcmp(command, "hint")) ; else if(!strcmp(command, "computer")) comp = 1; else { //convert easy & hard to "option" after treating their effect on the adapter if(!strcmp(command, "easy")) { @@ -620,6 +625,7 @@ DoCommand () computer = NONE; } else if(!strcmp(command, "quit")) { EPRINT((f, "# quit\n")) fflush(toE), exit(atoi(line+4)); } + else printf("Error (unknown command): %s\n", command); fflush(stdout); }