winboard interface questions

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: winboard interface questions

Post by hgm »

mike_bike_kite wrote:The move is waiting to be sent but I'm not sure when to send it.
Well, that is wrong. You should not be waiting to send amove, but waiting to recieve one. In Chess white usually moves first, and you should wait your turn. So send the move only after you received the white move (or "go").
I was sort of expecting that the program should wait until it gets sent a "go" before sending a move (if it's white) or should just reply with a move if it's given a move (black). Obviously this is not the case.
I don't see from what you conclude that last statement. The engine should wait for a move or 'go'. But it gets neither (apparently because you do not enter a white move to the GUI and do not click "Mode -> Machine White" there). So it keeps waiting, as it should.

If it is not the engine's turn, it should wait until it gets to be its turn. Either because a move is done and the other side gets the turn, or because the side it is playing for is changed through a 'go' command to the side that currently has the move.

Some examples (unfortunately posting them messes up the tabbing, so I am not sure they are still readable :( ):

Code: Select all

// sample 1: engine plays black, ponder on

GUI->engine		engine->GUI					REMARKS
xboard									some engines use this to switch out of stand-alone or UCI mode
protover 2								invite engine to send feature command
			feature memory=1				engine tells GUI how it wants to be treated
			feature ping=1
			feature setboard=1
			feature analyze=0
			feature option="Resign -check 0"
			feature done=1
accepted memory								let engine know GUI supports the requested features too
accepted ping
accepted setboard
accepted analyze
rejected option Resign							GUI apparently does not support engine-defined options
accepted done								engine has sent all its features; proceed immediately
memory 64								engine supported memory command, so tell it to use 64MB
new									start a game
level 40 1 0								40 moves/min
post									enable thinking output
hard									ponder on
ping 1									engine supported ping,check whether it received 'new'
time 6000								6000 centi-seconds on engine's clock
otim 6000								opponent's clock
g2g4									white move
			pong 1						engine has seen ping 1,so what followsmust be from the current game
			1     5     0     21 e7e5			engine thinking output (in response to 'post' command)
			2     1     0    380 e7e5 g1f3
			3     6     1    625 e7e5 g1f3 b8c6
			move e7e5					engine moves
			1     5     0      1 (g1f3) b8c6		and starts pondering
			2     2     0     30 (g1f3) b8c6 f1c4
time 5989
otim 5800
f2f4
			1    20     0     30 d7d5
		        2 29999     0     45 d8h4
			move d8f4
			0-1 {checkmate}					engine claims game
result 0-1 {checkmate}							notify engine of game result


// Protocol v1 engine plays white non-ponder game, using GUI book			

GUI->engine		engine->GUI					REMARKS
xboard									some engines use this to switch out of stand-alone or UCI mode
protover 2								invite engine to send feature command



new									engine does not respondwithin reasonable time; start a game
level 40 1 0								40 moves/min
nopost									disable thinking output
hard									madness: first switch ponder on
easy									and then off again (to accomodate non-compliant engines that toggle on 'easy')
force									put engine in force mode
e2e4									load book moves
e7e5
g1f3
b8c6
f1c4
f8c5
e1g1									enter castling as King move!
a7a5
time 6000								6000 centi-seconds on engine's clock
otim 6000								opponent's clock
go									set engine to play current stm (which is white)
			move g8f6
time 5930
otim 5999
f3g5
			move d7d5
time 5820
otim 5900
g5f7
			move e8f7
result 1-0 {white resigns}

// engine plays white FRC game

GUI->engine		engine->GUI					REMARKS
xboard									some engines use this to switch out of stand-alone or UCI mode
protover 2								invite engine to send feature command
			feature done=0					engine informs GUI it is going to require some time (initializing tablebases)
			feature memory=1 ping=1 setboard=1		send several features in one command
			feature variants="normal,fischerandom"
			feature egt="nalimov,gaviota,scorpio"
			feature usermove=1 done=1
accepted done								let engine know GUI supports the requested features too
accepted memory
accepted ping
accepted setboard
accepted variants
accepted egt
accepted usermove
accepted done
memory 68
egtpath nalimov H:\tablebases						machine has nalimov tablebases installed at given location
egtpath scorpio F:\chess\bitbases					machine has scorpio bitbases installed at given location
new									start a game
variant fischerandom							FRC game
setboard qrnnbkrb/pppppppp/8/8/8/8/PPPPPPPP/QRNNBKRB w GBgb - 0 1	initial position
level 40 1 0								40 moves/min
nopost									disable thinking output (mainly so I don't have to type it here...)
hard									ponder on
ping 1									engine supported ping,check whether it received 'new'
time 6000								6000 centi-seconds on engine's clock
otim 6000								opponent's clock
go									set engine to play stm (= white here)
			move O-O					in FRC, use O-O and O-O-O for castling
time 5900
otim 5820
usermove g7g6								engine requires 'usermove' keyword to recognize input moves
			move g2g3

// analysis with engine

GUI->engine		engine->GUI					REMARKS
xboard									some engines use this to switch out of stand-alone or UCI mode
protover 2								invite engine to send feature command
			feature analyze=1 ping=1 setboard=1
			feature san=1					madness: engine requires SAN input
			feature done=1
accepted analyze							let engine know GUI supports the requested features too
accepted ping
accepted setboard
accepted san
accepted done
new									start a game
level 40 1 0
post
hard
easy
setboard 4k3/8/8/8/8/8/4P3/4K3 w - - 0 1				relay the user set-up position to engine (leaves engine in force mode)
analyze									switch engine to analyze mode
			1   130     0     8 1.e4			analysis output (in SAN with move numbers, but is free format)
			2   127     0    20 1.e4 Ke7
			3   130     1    98 1.e4 Ke7 2.Ke2
Kf2									user entered move, sent as SAN because engine requested feature san=1
			1  -125     0     6 1...Ke7			analysis of new position
			2  -130     0    25 1...Ke7 2.e4
Ke7									new user move
			1   125     0     1 2.e4			analysis of new position
			2   123     0     2 2.e4 Ke6
			3   125     0    16 2.e4 Ke6 3.e5
undo									user took back Ke7
			1  -125     0     6 1...Ke7			analysis of old position
			2  -130     0    25 1...Ke7 2.e4
exit									stop analyzing,leaves engine in force mode
quit									terminate engine process

// starting from setup position

GUI->engine		engine->GUI					REMARKS
xboard									some engines use this to switch out of stand-alone or UCI mode
protover 2								invite engine to send feature command
			feature ping=0 setboard=0			send several features in one command
			feature done=1
accepted ping								let engine know GUI supports the requested features too
accepted setboard
accepted done
new									start a game (sets white to move)
force									prevent engine will start playing after a2a3
a2a3									kludge to set black to move
edit									engine did not support setboard, so use edit command
#									clear board
Ke1									put white King
Pe2									put white Pawn
c									switch to black
Ke8									put black King
.									leave edit mode (black is still to move; editing the board did not change that)
level 40 1 0								40 moves/min
nopost									disable thinking output
hard									ponder on
time 6000								6000 centi-seconds on engine's clock
otim 6000								opponent's clock
go									set engine to play stm (= black here)
			move e8e7					engine moves for black


// Note that most engines send a truckload of non-compliant garbage to the GUI, that should be ignored. Like

			Hello, this is Xxxx, have a nice game!
			start searching
			pondering on move d7d5
mike_bike_kite
Posts: 98
Joined: Tue Jul 26, 2011 12:18 am
Location: London

Re: winboard interface questions

Post by mike_bike_kite »

H.G.Muller wrote:You should not be waiting to send amove, but waiting to recieve one.
That's actually just what it's doing. It's waiting for a move or a "go" command or a "force" command. Then it will send it's reply.

How does an engine know if it's playing black or white? if an engine assumes it's white then both sides will try and send e2e4 (or similar). If engines assume to be black (which is what I'm doing) then they will just sit there forever waiting for a move. I don't see anything in the dialogue to tell me when to send my go. At the moment I'm assuming I'm black and waiting for a move, a force or a go?

Does a move have the keyword "move" in front of it? In the above example some have "move" and some don't. I read elsewhere they have "usermove" in front of them. I'm a bit confused.

I sent a move to winboard and it appeared in the logs but it didn't do anything with it (it didn't appear on screen) - had I missed something?

Does my engine have to send a list of features? I don't have too many features yet.
Evert Glebbeek wrote:You can send a move when there's a game in progress and if it's your move.
By default the engine plays black, but you should implement the commands for setting the colour the engine plays.
In the last debug output I posted I'm not told that I'm white or black. If I just assumed it was black then it would still be sitting there now waiting for whites move. I ended up sending a move when I received the "hard" command but this wasn't processed though it appeared in the log.

It's obviously an issue in my understanding but I just don't know what the program wants me to send?
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: winboard interface questions

Post by Evert »

How does an engine know if it's playing black or white?
It plays black unless told otherwise.
Does a move have the keyword "move" in front of it? In the above example some have "move" and some don't. I read elsewhere they have "usermove" in front of them. I'm a bit confused.
When you send a move, it has "move" in front of it. When you receive a move, it is just the plain move itself (in long algebraic notation).
You can request that moves you receive have "usermove" in front of them through the feature list.
mike_bike_kite wrote:
Evert Glebbeek wrote:You can send a move when there's a game in progress and if it's your move.
By default the engine plays black, but you should implement the commands for setting the colour the engine plays.
In the last debug output I posted I'm not told that I'm white or black. If I just assumed it was black then it would still be sitting there now waiting for whites move. I ended up sending a move when I received the "hard" command but this wasn't processed though it appeared in the log.

It's obviously an issue in my understanding but I just don't know what the program wants me to send?
After "new", the engine plays "black" (see the description of what the engine should do in response to "new" at http://home.hccnet.nl/h.g.muller/engine-intf.html). You keep track of whose turn it is. If it is the engine's turn, then the engine starts thinking and eventually returns a move. Send the move to xboard.
If it is not the engine's turn and you receive a "go" command, switch the side that the engine is playing. It will then find that it is playing the side that is currently on move and should start thinking as normal.
mike_bike_kite
Posts: 98
Joined: Tue Jul 26, 2011 12:18 am
Location: London

Re: winboard interface questions

Post by mike_bike_kite »

I think I have it solved! I called winboard from the command line and specified a first and second computer but it turned out I needed to change the Mode setting in the front end to "2 machines" as well. It is now playing itself happily. It still doesn't like much of the input but the moves are appearing now.

Thanks for your help.
User avatar
hgm
Posts: 27807
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: winboard interface questions

Post by hgm »

Well, like I wrote the very first time we discussed WB protocol, if your aim is to just play engine-engine matches, you can safely ignore most of the commands the GUI sends you. The important ones are 'new', 'force', 'go' and a (long-algebraic) move. And when you implement time managemaent (rather than just hard-coding it for a certain speed, and hope for the best), you can add 'level' and 'time' to that. For a graceful exit you might add 'quit' to the list. In the other direction it is really only the moves that matter, but it is essential they are prefixed with 'move' (unlike GUI->engine moves!).

As to the 'feature' commands: this is known as version 2 of the protocol, and the engine can send them in response to 'protover 2'. It is advisable to send at least 'feature done=1', as WinBoard will be waiting for that with a generous timeout before drawing the conclusion it is dealing with a version-1 engine, and proceeding with default settings. So the 'feature done=1' speeds up things appreciably. You should then be prepared to get an 'accepted done' reply from the GUI, which you again can completely ignore.

A nice next step could be to accept the 'setboard' command, so the engine can also play from a setup position. To get the GUI to send it to you, you should send 'feature setboard=1' in reply to the 'protover 2'.

If in addition to engine-engine matches you want to support human-engine through WinBoard, the command 'undo' and 'remove' are useful, so the user can take back moves. (But as you have your own GUI to play humans, there is not much need for you to do that.)

To implement pondering, you just have to react to the commands 'easy' and 'hard', which will automatically be sent. If you want to offer the user a glimpse of what the engine is thinking about, you can make the engine take note of the 'post' / 'nopost' commands, and let it print search output (when'post' is in effect) in the format 4 integers followed by a text, where the integers represent depth (in ply), score (in centi-Pawn), time (in centi-seconds) and number of searched nodes, and the text is the principal variation. You can let the engine send this whenever it likes, but good moments would be when an iteration finishes, and perhaps whenever a better move is found in the root.

As for the operation of WinBoard: starting from the command line you can use the "-mg N" option to automatically play a match of N games with alternating colors. Note that you can also enter this in the "Additional options" field of the WinBoard startup dialog, where you can also select the engines (once you installed them). You can also start the match from the menu (Mode->Machine March). In the 4.5-TM version you can also domulti-player tournament forms (e.g. a gauntlet for your engine with many different opponents).
mike_bike_kite
Posts: 98
Joined: Tue Jul 26, 2011 12:18 am
Location: London

Re: winboard interface questions

Post by mike_bike_kite »

I actually have most of the commands working though the default time control is (40 moves in 5 minutes) doesn't easily fit into my framework. I can also only get my program running from the command line - I can't work out how to add the engine into winboard yet.

My aim is to get the program playing against rated opponents (computer or human) so I can get an ELO rating (no matter how humble). It would also be fun to play it in one of the low ranking tournaments you mentioned. This is all a little bit down the line at the moment though.

Is there a way of setting an opponent program's ELO at say 1700? or even better allowing the programs to keep playing with one side adjusting the ELO until you have a figure?
User avatar
hgm
Posts: 27807
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: winboard interface questions

Post by hgm »

To make the engine appear in the comboboxes of the WinBoard startup dialog, you would have to add the line

"java -jar chess.jar engine"

to the engine list in the winboard.ini file (WinBoard-4.5-TM has a menu item "Engine->Edit Engine List" for that). You could also install it through the "Engine->Load Engine"menu dialog. In that case you would have to type

java

for the engine executable, and give

-jar chess.jar engine

as parameters. You would probably want to give it a nickname as well, for otherwise WinBoard would use the name "java" for it in the Select-Engine pull-downs in Load Engine and Tournament dialogs, which in this case it not very sensible.

I have little experience with engines with adjustable Elo; I have the impression that in the best case these would not be very well calibrated. It is probably better to just use a number of not artificially weakened engines of known Elo (e.g. from the WBEC or RWBC list), and just let your program play 20 games (from the Nunn opening lines) against each of those overnight, and see against which one you score ~50%.
mike_bike_kite
Posts: 98
Joined: Tue Jul 26, 2011 12:18 am
Location: London

Re: winboard interface questions

Post by mike_bike_kite »

It now appears in the list but I can't see where I assign a nickname. I guess I have to use an ini file as I can't see a menu option.

The winboard screen shows a simple 5 minute countdown clock. I assumed I'd get something like "level 0 5 0" from winboard to indicate the time control but instead I get "level 40 5 0" which is something completely different!

WBEC/RWBC tournament. Can I do this through winboard? Is it something that's easy to do?
User avatar
hgm
Posts: 27807
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: winboard interface questions

Post by hgm »

mike_bike_kite wrote:It now appears in the list but I can't see where I assign a nickname. I guess I have to use an ini file as I can't see a menu option.
The nickname could be set when installing the engine through the Load Engine dialog. It realy uses a kludge to acheive the nickname effect, by installing the engine with the line

"nickname" -fcp "java -jar chess.jar engine"

WinBoard interprets this as

-fcp "nickname" -fcp "java -jar chess.jar engine"

and the second -fcp option overrules the first, so that the first stays without any effect. Except that the shortcut names that appear in th epull-down menus will now be derived from it, in stead of from the true engine command.
The winboard screen shows a simple 5 minute countdown clock. I assumed I'd get something like "level 0 5 0" from winboard to indicate the time control but instead I get "level 40 5 0" which is something completely different!
It is different,but also would give you 5 min on the clock counting down. Diference is that after 40 moves,you nowwould get another 5 min added to your clock.

You can specify the time control with the Options->TimeControl dialog.If you want a sudden-death TC, select incremental, and set the increment to 0. This would also be the way to specify it from the command line:

-tc 5 -inc 0
WBEC/RWBC tournament. Can I do this through winboard? Is it something that's easy to do?
Yes, it should be easy to do tournaments with WinBoard (assuming you are using the 4.5-TM version that has a Tournament dialog in the Options menu). You should first download and unpack suitable opponent engines, though (many engines can be obtained from the WBEC website), and configure WinBoard to use them (through the Load Engine dialog). After that it would just be a matter of selecting the engines you want to participate from the pull-down menu in the Tournament dialog, select the tourney type and number of games per pairing, the PGN filewith opening lines (e.g. Nunn.pgn that comes with WinBoard), and press OK.

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

Re: winboard interface questions

Post by mike_bike_kite »

Brilliant - I can tell this will keep me amused for hours :)