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
}
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
// 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; }
}
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
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);
// 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