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.
\r
main()\r
{\r
- int engineSide=NONE; // side played by engine\r
+ int engineSide=NONE; // side played by engine\r
MOVE move;\r
int i, score, curVarNr;\r
\r
- Init(V_CHU); // Chu\r
+ setvbuf(stdin, NULL, _IOLBF, 1024); // buffering more than one line flaws test for pending input!\r
+\r
+ Init(V_CHU); // Chu\r
seed = startTime = GetTickCount(); moveNr = 0; // initialize random\r
\r
while(1) { // infinite loop\r
\r
- fflush(stdout); // make sure everything is printed before we do something that might take time\r
+ fflush(stdout); // make sure everything is printed before we do something that might take time\r
*inBuf = 0; if(moveNr >= 20) randomize = OFF;\r
//if(moveNr >20) printf("resign\n");\r
\r