Author: Uri Blass
Date: 02:00:38 11/20/04
I discovered a bug when movei tried to calculate perft in pgn and it simply told me that there is an error in the pgn when there was no error. After investigating it for hours I found the problem. 1)Movei is using a global variable with the name buffer like Crafty both for the pgn moves and for the winboard commands. It turned out that the content of buffer was deleted during perft and it took me few hours to find it. The next question was why did it happen? Crafty also use buffer for the same target so using global variable for both targets should not be a problem After few hours I found that 2 is correct: 2)Movei checks for user input every 8192 nodes so it found that there was a user input after calculating enough perft 2 and summerizing the nodes. Why there was a user input? 3)after some time I found that the function to create book simply used scanf so the computer assumed that there was a user input or in other words stdin->_cnt>0. What I learn from this story is that if I use scanf that is not related to winboard commands then I need also to clear the information in case that the computer cannot be in winboard mode. finally I am forced to understand better what stdin->_cnt > 0 means. If I understand correctly 1)fgets(...,...,stdin) has stdin->_cnt=0 inside of it or at least they reduce the value of stdin->_cnt 2)scanf or winboard commands that the engine does not listen to them have stdin->_cnt=x for x>0 inside of it. 3)sscanf at least reduce stdin->_cnt relative to scanf. I copied comments from dieter but it seems that his explanation was not good enough for me to understand exactly when stdin->cnt>0. Not that the same bug did not happen when trying to calculate perft from epd file because movei did not use scanf as preparing action but only sscanf . For the record here are Dieter's comments(of course the code and the comments helped me but there is a room for improvement in the comments and I think that my comments are also not perfect). /* When using Standard C input functions, also check if there is anything in the buffer. After a call to such functions, the input waiting in the pipe will be copied to the buffer, and the call to PeekNamedPipe can indicate no input available. Setting stdin to unbuffered was not enough, IIRC */ Uri
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.