Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Engine programming - standard input

Author: Dieter Buerssner

Date: 08:55:37 12/03/03

Go up one level in this thread


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().

>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).

Regards,
Dieter



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.