From: H.G.Muller Date: Sat, 11 Oct 2014 09:51:07 +0000 (+0200) Subject: Attempt to fix getting trapped in ponder mode X-Git-Url: http://winboard.nl/cgi-bin?p=hachu.git;a=commitdiff_plain;h=73f8d53961524d71089ad54b1549a953efa0fe14 Attempt to fix getting trapped in ponder mode HaChu was sometimes trapped in its ponder search, because the pending input that should wake it up out of ponder (i.e. the opponent's move) had been read from the pipe to the input buffer, hiding it from the test for pending input. Buffering linewise might prevent commands to be buffered before HaChu actually starts to read them. --- diff --git a/hachu.c b/hachu.c index 52355e8..fdf5bb4 100644 --- a/hachu.c +++ b/hachu.c @@ -2646,16 +2646,18 @@ printf("# ponder hit\n"); main() { - int engineSide=NONE; // side played by engine + int engineSide=NONE; // side played by engine MOVE move; int i, score, curVarNr; - Init(V_CHU); // Chu + setvbuf(stdin, NULL, _IOLBF, 1024); // buffering more than one line flaws test for pending input! + + Init(V_CHU); // Chu seed = startTime = GetTickCount(); moveNr = 0; // initialize random while(1) { // infinite loop - fflush(stdout); // make sure everything is printed before we do something that might take time + fflush(stdout); // make sure everything is printed before we do something that might take time *inBuf = 0; if(moveNr >= 20) randomize = OFF; //if(moveNr >20) printf("resign\n");