Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: How to poll stdin during thinking? - additional info...

Author: Jon Dart

Date: 06:59:42 12/13/01

Go up one level in this thread


Dieter's advice is good. Most programs set buffer size to zero to avoid the
problems he mentions with stdin, stdout. Lots of programs have sample source
code to handle this, including mine (http://www.arasanchess.org).

There are other factors to consider if you want to support pondering (thinking
on the opponent's time). I'm *still* fixing bugs in Arasan's Winboard module
related to this. The main problem is that you can have end of game indicators
(like "result") come in at various times .. in the pondering search, in the
regular search, and in between. I saw problems mostly playing against other
programs on a LAN or on the same machine. ICC has enough lag so that you get a
lot fewer race conditions there.

--Jon

On December 12, 2001 at 12:26:13, Dieter Buerssner wrote:

>On December 12, 2001 at 11:43:05, Severi Salminen wrote:
>
>>>In what language? At what platform? It can't be done in any portable fashion.
>>
>>Oh, sorry, I forgot to tell. PC/WIN98 and Visual C++ 6.0. And I have done it in
>>C only, so no C++. I hope this info might help :)
>
>In the other post, you said, you wanted no multithreading approach. It might be
>enough for you, if you read the documentation of PeekNamedPipe. This function
>can tell you, if there is input available from the pipe between WB and your
>engine. For non-WB mode, you can use _kbhit().
>
>Essentially the same code samples can be found in Crafty, Amy, Arasan, ...
>which (I believe) don't use multithreading for input processing.
>
>Some care must be taken, when using buffered Standard C input functions for
>reading stdin. Because the first usage of such a function will copy a lot (or
>all) of the contents "waiting" in the pipe to the buffered I/O system. So, now
>input may be waiting there, while PeekNamedPipe will show no input available.
>
>An unportable way to check for this, is looking at stdin->_cnt, which will be
>nonzero when input is waiting there.
>
>I personally find the Unixish select() method cleaner. Perhaps, some compability
>library is available for this.
>
>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.