Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Winboard for Dummies

166 views
Skip to first unread message

Russell Reagan

unread,
Jun 30, 2001, 2:24:38 AM6/30/01
to
I'm attempting to implement Winboard support into my chess program, but I'm
not having very much success. Basically (as I see it) all that is going on
is that my program and Winboard are sending messages back and forth, but I
have no idea how to actually implement this. In the article I read about
it, it gave several functions to use, but I don't know where I'm supposed to
use them, what parameters to specify, etc. I'm also a little fuzzy on the
buffered input thing and why that doesn't work. I'm just overall unclear
about how to implement everything from setting up the engine to work with
winboard to sending and recieving the messages, and confirming that
everything is working as it should. I'm not following the explaination of
these imaginary "pipes" that are described and things like that.


Jerry van Dijk

unread,
Jun 30, 2001, 7:00:19 AM6/30/01
to

"Russell Reagan" <rre...@mail.utexas.edu> writes:

> I'm attempting to implement Winboard support into my chess program, but I'm
> not having very much success. Basically (as I see it) all that is going on
> is that my program and Winboard are sending messages back and forth, but I
> have no idea how to actually implement this.

I only did the reverse (have a program talking to several winboard engines)
and found the easiest way was to use multiple threads (actually, as I use
Ada 95, I simply used multiple tasks).

> In the article I read about
> it, it gave several functions to use, but I don't know where I'm supposed to
> use them, what parameters to specify, etc.

The winboard 2 spec that is at least included with the winboard distribution
on Tim's site is quite good for this.

> I'm also a little fuzzy on the
> buffered input thing and why that doesn't work.

Read the explanation several times (no kidding!) and try to imagine what is
exactly happening in both the programs.

> I'm just overall unclear
> about how to implement everything from setting up the engine to work with
> winboard to sending and recieving the messages, and confirming that
> everything is working as it should.

Actually, the basic functionality is not that difficult. Maybe you should
read a bit first on concurrency and interprocess communication.

> I'm not following the explaination of
> these imaginary "pipes" that are described and things like that.

See paragraph above :-) Although pipes (in winboard context) is simply
coupling one programs output to another's input, and vice versa.

See the source code of any winboard engine for examples.

Succes,
Jerry.

--
-- Jerry van Dijk | email: jva...@attglobal.net
-- Leiden, Holland | web: home.trouwweb.nl/Jerry

l. dijksman

unread,
Jun 30, 2001, 8:54:19 AM6/30/01
to
Hi Russell,
maby you can ask this question better in the Winboard
Forum:

http://f11.parsimony.net/forum16635/

Leo.

"Russell Reagan" <rre...@mail.utexas.edu> schreef in bericht
news:9hjr8p$hkr$1...@oprah.cc.utexas.edu...

Robert Hyatt

unread,
Jun 30, 2001, 10:02:25 AM6/30/01
to

The "short answer" is as follows:

1. to send something to xboard, you simply write to stdout and that will
magically go to xboard. TO read something from xboard, you simply read
from stdin and that will magically receive whatever xboard wants to send to
you. Nothing special required there.

2. the complicated part of things deals with asking the question "do I have
any data in stdin that I need to read right now?" This happens when you
introduce "pondering" to your engine, so that while waiting on a move from
your opponent (xboard/winboard) you continue to compute. To make this work,
you have to occasionally ask "is there any data to be read?" and if you use
buffered I/O this won't work. Here is why:

When data comes in to your program via stdin, it goes into an operating
system buffer. When you ask if there is any data present, using select()
in unix or peeknamedpipe() in windows, those calls check the system buffer.
Assume that by the time you check, you have three lines to read (xboard/
winboard sends the "move" and "time" and "otim" to you as three separate
lines. If you use a buffered I/O call (scanf for example) the C library
will read all three lines into its own buffer, and then give you the first
one. Now peeknamedpipe() or select() won't be able to tell you that there
are two more lines to read, since they have been removed from the system
buffer and copied to the c library's buffer.

The solution is to use non-buffered I/O (I use read()/write() to get around
the library buffer problem).

--
Robert Hyatt Computer and Information Sciences
hy...@cis.uab.edu University of Alabama at Birmingham
(205) 934-2213 115A Campbell Hall, UAB Station
(205) 934-5473 FAX Birmingham, AL 35294-1170

Leen Ammeraal

unread,
Jun 30, 2001, 10:15:55 AM6/30/01
to
At risk of telling you no news,
the first thing you should know about
WinBoard programming is that you
only need to write a console application,
with standard input and output
(such as scanf and printf in C).
In his file engine-intf.html, Tim Mann
describes the commands your program should
read and write in detail.
If you have downloaded WinBoard, this
file is probably already on your machine.
I fully agree with you that the section about
buffering and so on looks very complicated.
If I remember well, I did not pay very much
attention to it, but to my surprise all worked
well. Of course, you need not implement all
features at once. Just start with the simplest
possible version.
Leen Ammeraal
http://home.wxs.nl/~ammeraal/

Russell Reagan <rre...@mail.utexas.edu> wrote in message
news:9hjr8p$hkr$1...@oprah.cc.utexas.edu...

Bruce Moreland

unread,
Jun 30, 2001, 4:09:28 PM6/30/01
to
Go here:

http://www.seanet.com/~brucemo/gerbil/gerbil.htm

Get Gerbil. There is a file called "engine\prot_e.c". If you implement the
functions in that so that they'll talk to your engine, then you link your
engine, prot_e.obj, and compiled instances of the files in the "winboard"
subdirectory, you'll have a Winboard engine.

Please let me know if you attempt this. I would like to know if you succeed
and I would like to help if you can't figure it out.

bruce

Russell Reagan <rre...@mail.utexas.edu> wrote in message
news:9hjr8p$hkr$1...@oprah.cc.utexas.edu...

Russell Reagan

unread,
Jun 30, 2001, 6:33:16 PM6/30/01
to
Thanks guys for the help. I've taken a look at several examples (Gerbil,
Crafty, TSCP, etc.) and I think I'm starting to get the idea of how all of
this is implemented. One other question though. How do I run my engine
with Winboard? I looked at GNU Chess, and it looks like they ran
winboard.exe with some command line parameters. It looks like one of the
parameters is the name of the console program (gnuches5), but I was
wondering what the other command line parameters are.

Also, how does my program know if it's supposed to use Winboard or simply
run as a normal console program? From a quick look at TSCP, I would assume
that Winboard sends my program an 'xboard' message, is that correct?

Thanks for all of your help. I really appreciate you guys. Especially Dr.
Hyatt and Bruce Moreland. You two guys have been answering a lot of my
beginner chess programming questions and I really appreciate it. It's great
to have authors of such strong chess programs as you two guys right here
asnwering all of my questions, which I'm sure you have answered many times
before. And I thought that the name Leen Ammeraal sounded familiar, but I
wasn't able to put the name with being a famous C++ author. Thanks to all
of you.

Russell


Dieter Buerssner

unread,
Jul 1, 2001, 9:32:37 AM7/1/01
to
Robert Hyatt wrote:

>The solution [to inconsitencies caused by select and buffered I/O]


>is to use non-buffered I/O (I use read()/write() to get around
>the library buffer problem).

An alternative is to use setvbuf to set stdin to unbuffered or line
buffered (I think on most systems, when stdin is a pipe, it will be fully
buffered, when it is a terminal, it will be line buffered by default).
Then still the standard C I/O functions can be used.

Regards,
Dieter

Bruce Moreland

unread,
Jul 1, 2001, 1:18:09 PM7/1/01
to

Dieter Buerssner <bu...@gmx.de> wrote in message
news:9hngf3.3...@buerssner-17104.user.cis.dfn.de...

I just made a wrapper around "printf", which include an "fflush". Works
like a charm.

bruce

Dieter Buerssner

unread,
Jul 2, 2001, 11:07:11 AM7/2/01
to
Bruce Moreland wrote:

>I just made a wrapper around "printf", which include an "fflush". Works
>like a charm.

Sure, I am doing the same. But this will no solve the problem described
by Robert concerning input. Output is easy IHMO, and can be done with
Standard C means. Checking for input, is another problem, for which
system specific code is needed (like select). And select works on
file descriptors (which are not a Standard C feature) and not on streams
(FILE *).

Regards,
Dieter

Daniel Lidström

unread,
Jul 3, 2001, 5:14:41 PM7/3/01
to

"Russell Reagan" <rre...@mail.utexas.edu> wrote in message
news:9hljuk$n32$1...@oprah.cc.utexas.edu...
[...]

> this is implemented. One other question though. How do I run my engine
> with Winboard? I looked at GNU Chess, and it looks like they ran
> winboard.exe with some command line parameters. It looks like one of the
> parameters is the name of the console program (gnuches5), but I was
> wondering what the other command line parameters are.

I know this is in the winboard help file. Have you read it?
P.S. Take a look in winboard.ini


Daniel Lidström
danli97(at)ite.mh.se
http://www.ite.mh.se/~danli97/

62 23' 25" N
17 15' 31" E


Mike Leahy - Bookup

unread,
Jul 6, 2001, 10:34:37 AM7/6/01
to

"Russell Reagan" <rre...@mail.utexas.edu> wrote in message
news:9hjr8p$hkr$1...@oprah.cc.utexas.edu...

> I'm attempting to implement Winboard support into my chess program, but
I'm
> not having very much success.
<snip>

> I'm not following the explaination of
> these imaginary "pipes" that are described and things like that.

On the chance that you're using Delphi, I recently licensed
a bunch of copies of my Bookup pipe code (modeled after
winboard.c) to chess developers. It is rather arcane stuff,
I think.

Mike Leahy
"The Database Man!"
http://www.bookup.com


Mickael Faivre-Macon

unread,
Jul 27, 2001, 1:56:05 PM7/27/01
to
Hi,

If I use standard input function as gets(), getch(), scanf(), ... my
program freeze until he get something to read in the input buffer.

As it is a Windows GUI and not a non windowed program, it is not what
I want....

What function read the buffer and do not wait if the buffer is empty ?

Mickael.

Mickael Faivre-Macon

unread,
Jul 27, 2001, 8:54:06 PM7/27/01
to
Hi,

I found the solution :
PeekNamedPipe(GetStdHandle(STD_INPUT_HANDLE), NULL, 0, NULL, &nchar, NULL)
... gives me the nb of char in the input buffer when it is a pipe.

Mickael.

DWORD nchar;
DWORD dw;
char cmd_buf[100];
int cmd_buf_count = 0;
if (Pipe) {
if (PeekNamedPipe(GetStdHandle(STD_INPUT_HANDLE), NULL, 0,
NULL, &nchar, NULL)) {
int nextc;
if(nchar>0) MemoLog->Lines->Add(AnsiString("Nb char: ")+nchar);
for (unsigned i = 0; i < nchar; i++) {
nextc=getc(stdin);
if (nextc == '\n') {
cmd_buf[cmd_buf_count] = '\0';
cmd_buf_count = 0;
MemoLog->Lines->Add(AnsiString(">")+cmd_buf);
return;
}
else
cmd_buf[cmd_buf_count++] = nextc;
}
} // PeeknamedPipe
else {
MemoLog->Lines->Add(AnsiString("No peek"));
}
}
else {
MemoLog->Lines->Add(AnsiString("No pipe"));
}

0 new messages