From: H.G.Muller Date: Fri, 13 Apr 2018 06:53:06 +0000 (+0200) Subject: Implement 'pause' command X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=ddbdc08c383883adda17d366e18c819f2e6a4d3a;p=crazywa.git Implement 'pause' command The CECP 'pause' an 'resume' commands are implemente, and announced in the corresponding feature. Commands in paused mode are ignored, except 'quit'. The ReadClock() function has been adapted to allow initialization of the startTime with an offset, to give the paused time back to the clock. For this the nodeCount (which naturally stops incrementing during pauses) has to be reset outside ReadClock again. --- diff --git a/dropper.c b/dropper.c index 6d8ae23..a21fc21 100644 --- a/dropper.c +++ b/dropper.c @@ -1763,11 +1763,11 @@ int contemptFactor; // likewise int ReadClock (int start, int print) -{ +{ // 'print' indicates we want true time (i.e. not nodes-derived), or provides offset while resetting clock static int startTime; int t; if(nodeRate > 0 && !start && !print) return nodeCount*1000LL/nodeRate; t = (nodeRate >= 0 ? (int)(CPUtime()) : GetTickCount()); - if(start) startTime = t, nodeCount = 0; + if(start) startTime = t - print; return t - startTime; // msec } @@ -1849,7 +1849,7 @@ ReadLine () int DoCommand (int searching) { - char command[80]; + char command[80]; int paused = 0; while(1) { // usually we break out of this loop after treating one command @@ -1861,6 +1861,9 @@ printf("# command: %s\n", inBuf); // recognize and execute 'easy' commands, i.e those that can be executed during search if(!strcmp(command, "quit")) { exit(0); } // exit immediately + if(!strcmp(command, "resume")) { ReadClock(1, paused); return 0; } // continue searching + if(paused) continue; // during pause, keep reading, ignoring everything except quit and resume + if(!strcmp(command, "pause")) { paused = ReadClock(0, 1); continue; } // remember (true) time already used if(!strcmp(command, "otim")) { continue; } // move will follow immediately, wait for it if(!strcmp(command, "time")) { sscanf(inBuf+4, "%d", &timeLeft); continue; } if(!strcmp(command, "easy")) { ponder = OFF; return 0; } @@ -1897,7 +1900,7 @@ printf("# command: %s\n", inBuf); } if(!strcmp(command, "protover")){ printf("feature ping=1 setboard=1 colors=0 usermove=1 memory=1 debug=1 reuse=0 sigint=0 sigterm=0 " - "exclude=1 nps=1 myname=\"CrazyWa " VERSION "\"\n"); + "exclude=1 nps=1 pause=1 myname=\"CrazyWa " VERSION "\"\n"); printf("feature variants=\"crazyhouse,shogi,minishogi,judkinshogi,torishogi,euroshogi,crazywa,kyotoshogi," "5x5+4_shogi,5x5+5_shogi,6x6+6_shogi,7x7+6_shogi,11x17+16_chu\"\n"); printf("feature option=\"Resign -check 0\"\n"); // example of an engine-defined option @@ -1969,7 +1972,7 @@ main () if(stm == engineSide) { // if it is the engine's turn to move, set it thinking, and let it move {int i;for(i=0; i<=hashMask+3; i++) /*if(hashTable[i].score != hashTable[i].lim)*/ hashTable[i].lock = 0;} - forceMove = undoInfo.move = abortFlag = 0; ReadClock(1, 0); + nodeCount = forceMove = undoInfo.move = abortFlag = 0; ReadClock(1, 0); for(i=0;i<1<<16;i++) history[i] = 0; //>>= 1; for(i=0;i<1<<17;i++) mateKillers[i] = 0; score = Search(stm^COLOR, -INF, INF, &undoInfo, maxDepth, 0, maxDepth); @@ -1988,7 +1991,7 @@ main () // now it is not our turn (anymore) if(engineSide == ANALYZE) { // in analysis, we always ponder the position - forceMove = undoInfo.move = abortFlag = 0; ReadClock(1, 0); + nodeCount = forceMove = undoInfo.move = abortFlag = 0; ReadClock(1, 0); Search(stm^COLOR, -INF, INF, &undoInfo, maxDepth, 0, maxDepth); } #if 0