Automating Computer Play

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

gjwcarsaig

Automating Computer Play

Post by gjwcarsaig »

I've created a chess playing program in Basic which I have tested on ICC. It's not hugely strong but it plays a decent game (ELO roughly 1800).

When I test the program against other opponents (such as on ICC), I have to make the moves manually. This means the program loses several seconds each move, and makes blitz games almost impossible to play within the time.

I know there's a way of automating moves, but I have no idea how this is accomplished, as it would require communication between the two programs.

Can anyone shed any light on this?
Laurens Winkelhagen

Re: Automating Computer Play

Post by Laurens Winkelhagen »

Hi Gavin,

Congratulations on making a chess playing program:-)

There several protocol's in existence to provide a common language for computer chess engines and interfaces. The most common are the Xboard protocol and UCI.

If you implement either in your program, you can use one of several programs as a user interface or even as an interface to ICC / Freechess. These protocol's however would love to use the stdio-like functions as input/output, so that might require you to rewrite quite a bit in your program (which I assume is: http://gjwcarsaig.co.uk/).

The benefits are big though, as it will also allow you to automate test matches against other chess engines to test the strenght of your program. Also, a lot of people are interested in free 'winboard' engines so you will probably get a big increase in downloads when you implement UCI and/or Xboard protocol.

edit: I noticed your opening book looks like that of the open source program TSCP. He also wrote some code for winboard communication, which you can look at^^
Last edited by Laurens Winkelhagen on Tue Mar 17, 2009 1:14 pm, edited 1 time in total.
User avatar
Roman Hartmann
Posts: 295
Joined: Wed Mar 08, 2006 8:29 pm

Re: Automating Computer Play

Post by Roman Hartmann »

Hi,
you can either implement the UCI or the Xboard protocol in your engine in order to run it under a gui and let it play against other engines or on a chess server.
I'm not sure how easy that can be done in Basic though. Maybe someone else can point you to some example code how this could be done.

best regards
Roman
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Automating Computer Play

Post by Sven »

In case your program has its own GUI, you will most probably also want to allow your program to run without the GUI part, as a pure chess engine only doing standard input/output stuff. So either you make two different binaries which can both be started without providing any command line parameters, or you define command line options to run with and without GUI, and make one of both the default in case no arguments are given (e.g. double-click).

For these reasons, it might always be good to keep GUI code and other code strictly separate, ideally in different source files, with a well-defined interface.

Sven
User avatar
Bill Rogers
Posts: 3562
Joined: Thu Mar 09, 2006 3:54 am
Location: San Jose, California

Re: Automating Computer Play

Post by Bill Rogers »

If you do a search here for Thomas McBurney and email him, I am sure he can give you a coded solution, he did for me.
You must use FreeBasic and it is free for the interface to work. What he gave me was the commands for xboard and I used ply depth. If he can supply you with the code for seconds per move, I don't know but if he does then maybe you could forward it to me too.
My chess programs are written in Qbasic with the exception of the one that I implemented xboard for, they are in FreeBasic.
Good Luck
Bill
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Automating Computer Play

Post by hgm »

Make it so that your program is a pure console application (only text input and output). Then let it igore every input line except the following:

new
start a new game

a move of the type e2e4, e1g1, or a7a8q
accept the move, and let it produce an answer

level N M 0
with N and M decimal integers: set te time control to N moves in M minutes

go
start doing a move from the current position.

The only thing the program should ever print is a line of the type

move e2e4
(or any other move), to prnt the moves it does.

Once you have done that, you have implemented the minimal subset of the WB protocol that is needed to play games under WinBoard. Make sure to flush the output after every move you write.
CThinker
Posts: 388
Joined: Wed Mar 08, 2006 10:08 pm

Re: Automating Computer Play

Post by CThinker »

hgm wrote:Make it so that your program is a pure console application (only text input and output). Then let it igore every input line except the following:

new
start a new game

a move of the type e2e4, e1g1, or a7a8q
accept the move, and let it produce an answer

level N M 0
with N and M decimal integers: set te time control to N moves in M minutes

go
start doing a move from the current position.

The only thing the program should ever print is a line of the type

move e2e4
(or any other move), to prnt the moves it does.

Once you have done that, you have implemented the minimal subset of the WB protocol that is needed to play games under WinBoard. Make sure to flush the output after every move you write.
If you host the engine on ICC or FICS and use Winboard, you also need to support the "force" command. This will allow you to handle the resumption of interrupted games (say, due to disconnections, or just bad player behavior) which is common on these servers.

You may also want to support the "setboard" command if you will be testing engine-vs-engine matches from a set of given starting EPD positions.