From: H.G. Muller Date: Tue, 4 Dec 2012 22:37:53 +0000 (+0100) Subject: Implement pause / resume commands X-Git-Tag: v2.0~30 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=c3f4db2a7ba3c54f806a5972cf371ab6af416be1;p=uci2wb.git Implement pause / resume commands --- diff --git a/README.txt b/README.txt index afef1f8..fa4cbdc 100644 --- a/README.txt +++ b/README.txt @@ -46,6 +46,9 @@ H.G.Muller Change log: +4/12/2012 1.10 +Implement pause / resume commands + 9/5/2012 Fix bug in converting shogi moves, introduced in v1.8 diff --git a/UCI2WB.c b/UCI2WB.c index 78ab021..fbd9d74 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -1,6 +1,6 @@ /************************* UCI2WB by H.G.Muller ****************************/ -#define VERSION "1.9" +#define VERSION "1.10" #include #include @@ -30,7 +30,7 @@ #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, inex, on[500]; char currMove[20], moveMap[500][10]; // for analyze mode @@ -278,7 +278,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!) @@ -341,7 +341,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 @@ -377,6 +377,18 @@ GUI2Engine() if(!(sm & 2)) goto nomove; // no moves enabled; continue current search if(computer == ANALYZE) StopPonder(1); // abort old analysis } + else if(!strcmp(command, "pause")) { + if(computer == stm) myTime -= GetTickCount() - startTime; + suspended = 1 + pondering, StopPonder(1); // remember if we were pondering, and stop search ignoring bestmove + } + else if(!strcmp(command, "resume")) { + if(suspended == 2) { // restart interrupted ponder search + LoadPos(moveNr+1); + pondering = 1; lastDepth = 1; + StartSearch(" ponder"); + } + suspended = 0; // causes thinking to start in normal way if on move or analyzing + } else if(!strcmp(command, "xboard")) ; else if(!strcmp(command, "analyze"))computer = ANALYZE, collect = 1, sm = 0; else if(!strcmp(command, "exit")) computer = NONE, StopPonder(1);