From 73f8d53961524d71089ad54b1549a953efa0fe14 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Sat, 11 Oct 2014 11:51:07 +0200 Subject: [PATCH] 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. --- hachu.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) 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"); -- 1.7.0.4