Simple extensions?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: Simple extensions?

Post by tpetzke »

This is difficult if you can't play engine - engine matches.

What you can do is stress you engine with test suites and check how much positions it is able to solve

This one from Arsan is useful

http://sites.google.com/site/strategictestsuite/

If you run suite 1 - 10 and count the points you get there is an ELO estimator from the number of points you received. Don't know how accurate it is but better than nothing and you will have at least a measurement of improvement.

Thomas...
mike_bike_kite
Posts: 98
Joined: Tue Jul 26, 2011 12:18 am
Location: London

Re: Simple extensions?

Post by mike_bike_kite »

hgm wrote:The only way to find out is to play a hundred games or so against opponents of known rating. But that is a bit difficult if you don't have a standard interface that allows you to play automatically.
Is there a web page that describes a minimal interface. I looked into trying to code for your interface but couldn't find anything simple enough for me to understand.

I just needed a list of minimal commands that I had to cater for and examples for how moves are entered. A simple list of commands for a small game that included castling, an en passant and queening a pawn would be helpful. I could then try it by hand and then write a simple interface for my program afterwards.
mike_bike_kite
Posts: 98
Joined: Tue Jul 26, 2011 12:18 am
Location: London

Re: Simple extensions?

Post by mike_bike_kite »

tpetzke wrote:This one from Arsan is useful
It does look useful but the syntax they use is a bit of a pain. I think I have to decide whether to try and build a standard chess engine interface first.
User avatar
hgm
Posts: 27792
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Simple extensions?

Post by hgm »

mike_bike_kite wrote:Is there a web page that describes a minimal interface. I looked into trying to code for your interface but couldn't find anything simple enough for me to understand.
Well, I think I pointed you to this before (so apparently it counts a not being simple enough. :wink: ): http://www.open-aurec.com/wbforum/viewt ... 24&t=51739 . The first post in that thread gives C code of a rather elaborate implementation, but the second post discusses what minimal subset of that you would need to get something that works.

Since you programmed your own GUI, you actually have a choice how to do it: turn your program into an engine, so it could be run under WinBoard or Arena, or turn it into a general-purpose GUI, so that it could start up an engine process and request moves from it in stead of waiting for moves from the human.

Assuming you would want your program to behave as an engine, it would only have to react to the commands 'new' (by setting up a new game), 'go' (starting to play for the side that currently has the move), 'force' (switch to a passive mode, accepting moves for both sides, never thinking itself) and moves in long-algebraic notation. As output it would just have to print the moves it decides to play, prefixed by the word 'move'. That's it.

Example of two games:

Code: Select all

Input          Output
new
e2e4
               move e7e5
g1f3
               move b8c6
f1c4
               move f8c6
e1g1
               move g8f6
new
force
d2d4
d7d5
c2c4
e7e6
go
               move c4d5
e6d5
               move e2e3

When running under WinBoard you will get a lot more input, (trying to tell you how long it should think, how much time is left on your clock, how the game ended, or if the program should exit), but you could ignore all that for starters.
mike_bike_kite
Posts: 98
Joined: Tue Jul 26, 2011 12:18 am
Location: London

Re: Simple extensions?

Post by mike_bike_kite »

That was much simpler :) Trying to understand a new protocol in a language you don't code in is quite tough and I was a bit embarrassed to say I hadn't a clue what was required. Your simple examples help enormously and it all looks quite straightforward. I think I can do that moderately easily but I have a few small questions:

What do I actually connect to (I'm on an XP PC)?
Are time controls expected?
Is it told if it draws by repetition and how?
How is queening a pawn to something other than a queen communicated?
User avatar
hgm
Posts: 27792
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Simple extensions?

Post by hgm »

The engine has to be a console application, which you can run in a command-prompt box, where you type to, and which answers back by printing text in the box. You won't have to do any connection; the GUI will do that for you, setting up pipes to send and receive from the engine. The engine has never to be aware of this.

Time controls are more than just a protocol matter, but an essential part of the engine. I don't know which time controls you support now. The protocol supports four different modes of time control: N moves per M minutes repeating, ('classical'), M min per game ('sudden death'), M min starting time + S seconds per move ('incremental'), and S sec maximum per move (fixed). They are told to the engine through a combination of the 'st' and 'level' command. But even if your engine does not implement any of these modes, you could simply let it run using its own hard-coded mechanism for controlling its search duration, and have it ignore whatever the GUI requests. Most GUIs support a mode where the engine will not be forfeited when it exceeds time in the opinion of the GUI, and you could run in that mode, using the time-control settings of the GUI only for your opponents. If you want to do it officially, though, your engine should recognize the commands

st S

for fixed maximum time of S sec/move,

level 0 M S

for incremental or (with S=0) sudden death, and

level N M 0

for N moves in M min. Before every move, (or 'go') the GUI will send you a 'time T' and an 'otim T' command to inform you of the times indicated by the chess clock of you and your opponent (in centi-second). You will have to figure out yourself how many moves you will have to last on that time (depending on the st/level command received at the beginning of the game, and the number of moves done so far).

When the game finishes, the engine will be sent a 'result' command, like

result 1/2-1/2 {3-fold repetition}

There is not much reason to do anything with this, though. The GUI can keep complete records (store all games as PGN, including result and explanations), there is no reason to duplicate that in the engine. If the engine receives 'new' it can conclude the previous game finished, and just initialize itself for a new one. If I were you, this would be one of the last commands

Promotion piece is suffixed to the long-algebraic move in lower case, e.g.

a7a8n
mike_bike_kite
Posts: 98
Joined: Tue Jul 26, 2011 12:18 am
Location: London

Re: Simple extensions?

Post by mike_bike_kite »

Hopefully I'll have it playing in a day or two.
No doubt my poor little engine will be at the bottom of the league but c'est la vie.
It will definitely be good to give the program a rating though.
and thank you for your assistance - much appreciated.

Mike
User avatar
hgm
Posts: 27792
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Simple extensions?

Post by hgm »

There are hundreds of engines, and I am pretty sure there will be many that are far weaker than yours. (I made one ultra-weak engine, which is called N.E.G. 0.3d, and does not even have search. But it still wins games!) It will just be a matter of picking the proper opponents. A good place to hunt for weak engines is the ChessWar promo division ( http://www.open-aurec.com/chesswar ).
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: Simple extensions?

Post by tpetzke »

The syntax of the file is standard EPD format.

I don't like it either because moves a specified in a human centric way e.g. "N1xg3+" which makes it for a engine more difficult to process, the long algebraic notation of UCI is much simpler for an engine.

But it is the standard somehow and so whether I like it or not I had to implement it. Almost all test suites you encounter will follow that format, it is not just this single one.

The bonus with this suite however is the scoring of the sometimes 2nd or 3rd best moves. So even if your engine did not find the best move it is good to know that it found the 2nd best move at least. For that however you have to parse the c0 parameter to know what the other good moves and their scores are.
User avatar
hgm
Posts: 27792
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Simple extensions?

Post by hgm »

I think it will always be much easier (and more rewarding) to leave EPD file processing to the GUI, and just let the engine understand the protocol, than making the engine process EPDs by itself.