From: H.G.Muller Date: Fri, 7 Dec 2018 22:20:36 +0000 (+0100) Subject: Combine function of 'searching' and 'pondering' flags X-Git-Tag: v4.0~21 X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=commitdiff_plain;h=ed12bdda15cb49c351d1358a8d056a1f97c59f85;hp=0bcc18ddfe1e849b345a565850e2a14cdab30d1a Combine function of 'searching' and 'pondering' flags The vaiable 'searching', formerly used only to indicate if the engine was doing an analysis search, now indicates pondering if it has value 1, and analysis if it has value 2. This to simplify the state logic. --- diff --git a/UCI2WB.c b/UCI2WB.c index 0e7f34f..ae6cf2c 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -42,7 +42,7 @@ #define NONE 2 #define ANALYZE 3 -char move[2000][10], iniPos[256], hashOpt[20], pause, pondering, suspended, ponder, post, hasHash, c, sc='c', suffix[81], varOpt, searching, *binary; +char move[2000][10], iniPos[256], hashOpt[20], pause, suspended, ponder, post, hasHash, c, sc='c', suffix[81], varOpt, searching, *binary; 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, namOpt, comp; char currMove[20], moveMap[500][10], /* for analyze mode */ canPonder[20], threadOpt[20], varList[8000], anaOpt[20], backLog[10000], checkOptions[8192] = "Ponder"; @@ -189,7 +189,7 @@ StartPonder(int moveNr) { if(!move[moveNr][0]) return; // no ponder move LoadPos(moveNr+1); - pondering = 1; lastDepth = 1; + searching = 1; lastDepth = 1; StartSearch(" ponder"); } @@ -202,9 +202,9 @@ Analyze(char *val) int Release() { // send setoption commands backlogged during thinking to engine, aborting ponder or analysis search if necessary - int len = logLen - sentLen, analyse = searching; + int len = logLen - sentLen, analyse = (searching == 2); if(len <= 0) return 0; - StopPonder(pondering | searching); pondering = searching = 0; // force new search if settings change during analysis (multi-PV!) + StopPonder(searching); 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(moveNr); // (re)start ponder search return analyse; // return 1 if analysis search should be restarted @@ -264,8 +264,8 @@ HandleEngineOutput() DPRINT("# engine said: %s", line), fflush(stdout); if(sscanf(line, "%s", command) != 1) continue; if(!strcmp(command, "bestmove")) { - if(pause == 1) { pondering = pause = 0; Sync(WAKEUP); continue; } // bestmove was reply to ponder miss or analysis result; ignore. - else if(pondering) { pondering = 0; printf("%d 0 0 0 UCI violation! Engine moves during ponder\n", lastDepth+1); continue; } // ignore ponder search + if(pause == 1) { searching = pause = 0; Sync(WAKEUP); continue; } // bestmove was reply to ponder miss or analysis result; ignore. + else if(searching == 1) { searching = 0; printf("%d 0 0 0 UCI violation! Engine moves during ponder\n", lastDepth+1); continue; } // ignore ponder search // 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; } @@ -459,7 +459,7 @@ GUI2Engine() EPRINT((f, " searchmoves")) for(i=1; i 0) EPRINT((f, "# 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), searching = 0; + if(searching) StopPonder(1), searching = 0; moveNr = moveNr > i ? moveNr - i : 0; collect = (computer == ANALYZE); sm = 0; } else if(!strcmp(command, ".")) { @@ -616,7 +616,7 @@ DoCommand () else if(!strcmp(command, "xboard")) ; else if(!strcmp(command, "analyze"))computer = ANALYZE, collect = 1, sm = 0, Analyze("true"); else if(!strcmp(command, "exit")) computer = NONE, StopPonder(1), searching = 0, Analyze("false"); - else if(!strcmp(command, "force")) computer = NONE, StopPonder(pondering); + else if(!strcmp(command, "force")) computer = NONE, StopPonder(searching == 1); else if(!strcmp(command, "go")) computer = stm; else if(!strcmp(command, "ping")) { /* static int done; if(!done) pause = 1, fprintf(toE, "isready\n"), fflush(toE), printf("# send isready\n"), fflush(stdout), Sync(PAUSE); done = 1;*/ printf("po%s", line+2); } else if(!strcmp(command, "memory")) sscanf(line, "memory %d", &memory);