Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: winboard/xboard?

Author: Russell Reagan

Date: 15:26:14 05/29/02

Go up one level in this thread


On May 29, 2002 at 17:40:18, William H Rogers wrote:

>I know that there must be an "out" and an "in" command, but out to what, port1?
>Input from what port1? This is the confusing thing that is hanging me up right
>now. I have been told that I cannot interface with either one using Quickbasic,
>but I want to make sure. Can anyone shead some light on this subject.
>Thanks in advance
>Bill

You can interface with Winboard or XBoard using QBasic or any other language
that can write output to the console, or more specifically, write output to
standard output, and read input from standard input. All your program has to do
is send output like it would normally, and Winboard/XBoard will recieve that
output. Winboard/XBoard sets everything up for you beforehand, so if you want to
make a move on Winboard, you just do something like, 'PRINT "e2e4"' or however
it's done in QBasic (I haven't used it in a long time). I'll try to explain a
little bit about how this works.

Winboard and XBoard communicate with your chess engine through "pipes". Back in
the days when console operating systems were popular (and even today in Unix and
Linux), you could use pipes to accomplish cool things. For example, in Unix
there is a program named wc, which stands for "word count". It counts how many
letters, words, and lines are in a file. So if you wanted to know how many lines
were in a file, you could type the command "wc -l filename" (the -l is an option
to the word count command, telling it to only count the number of lines). In
Unix, we also have a program that will tell us which users are logged onto the
system, and the program's name is finger. There are others that do the same
thing, such as the "who" command and the "w" command. The program would put each
user's name on it's own line. Here's where pipes come into play. Let's say that
you wanted to know how many users were online. What a pipe does is take the
output of one program, and sends it as input to another program. So if you ran
the "who" program, you might get output that's a list of users, something like:

Russell
William
Bob
Dan

Now, if you had that information stored in a file named names.txt, you could
find out how many users were logged in using the word count command, like this:

wc -l names.txt

and the word count program would output:

4

So since a pipe takes the output of one program and sends it as the input to
another program we can create a pipe that will take the output of the "who"
command (that outputs a list of the users online), and send that data as input
to the word count command, and word count will tell us how many lines there are
in the input data, which in our example would be 4, which is the number of users
online. You would do this by using the pipe symbol | (vertical line). So you
could type this to find out how many users were online:

who | wc -l

and the output would be:

4

which is the number of users online.

So, what winboard and xboard do is basically use pipes like this. When you send
something to standard output (by using the PRINT command in QBasic), what is
really happening is that whatever you send as output is being sent to WinBoard
as input. And whatever Winboard sends as output is being sent to your program as
input. So when you did the INPUT command (if that's the correct command in
QBasic), it would NOT read from whatever you type in, but it would instead read
from whatever WinBoard is sending it. Winboard/XBoard takes care of everything
for you and gets it all setup beforehand.

There are a few things that I can think of offhand that might cause some
problems when using QBasic. There is a place where you specify the name of the
program to use as the chess engine in Winboard's command line arguments. If you
are using one of the interpreted versions of QBasic, then you will have to
invoke it via the interpreter, but I'm not sure what the name of the interpreter
is. Someone can tell you though, or you might already know. This shouldn't be a
big deal. If you use QBasic 4.5 or later, then it can compile executable files,
so this isn't even an issue if you're using one of those versions.

The other thing that might cause a problem is reading input and writing output
to Winboard. Even in C/C++ you have to do some extra things to make sure that
you are reading input correctly and writing output correctly. I would bet that
QBasic probably uses buffered input and output, which will cause some problems.
I'm sure there is some way around this, but it might not be easy. On the other
hand, it might not even be a problem, but keep these things in mind.

Anyway, I hope this helps some. If anything wasn't clear, just say so and I'll
try to clarify. Others should respond with some helpful advice as well I would
imagine.

Good luck,

Russell



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.