Author: Matt Thomas
Date: 22:46:17 12/03/03
Go up one level in this thread
On December 03, 2003 at 11:55:37, Dieter Buerssner wrote: >On December 03, 2003 at 09:43:38, Robert Hyatt wrote: > >>On December 03, 2003 at 05:08:14, Matt Thomas wrote: >> >>>I want to create a chess engine and am starting with the input/output routines. >>>I can handle output, but am not sure about how to implement input. I am >>>thinking to use ReadFile() to be unbuffered, and for pipes. I could implement a >>>loop to poll for input, but wouldn't that be a drag on CPU cycles? > >The typical method would be, to poll for input not all the time, but say for >example every 10000 nodes. The overhead will be small. The number 10000 can be >dynamically adjusted to the CPU and the time left. I would suggest, to not use >system specific functions for reading the input (for seeing if input is >available, system specific means are needed in C). So, instead of ReadFile, >perhaps fgets() or fgetc() (which are Standard C functions and portable to any >system). I use mainly fgets(). > I like the idea of using using some timer operation to poll input. I want to review input/output commands. I am programming on Win98, but I also have Mandrake,Win2k,XP, so it would be nice to have cross-platform/OS capabilities. I want to review threads also, they offer some interesting possibilities. >>1. use Read(). > >I guess Robert means read(). As said above, I would prefer Standard C functions >(if possible). read() is not a Standard C function. When using Standard C >functions, you probably must also set the buffer method for stdin to >non-buffered (perhaps line buffered is sufficient, because the WB-protocol uses >whole lines for all commands). For example with the Standard C function >setvbuf(). > >If done slightly careful, a WB-engine could be written with Standard C means >besides the input polling and some time function (practically a good resolution >of the times will be needed, especially when playing faster time controls). Yep, read about the bufferless situation from the Winboard protocol notes. I remember read() being a suggestion in those notes. I have to look around for my Bjarne Stroustrup book to review the standard. Been a while. Thanks for sharing your thoughts, Matt
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.