Opening books?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: Opening books?

Post by hgm »

Important in this context is that his engine is a web-application with its own, browser-based GUI. So that GUIs for standard protocols could do this for an engine speaking a standard protocol is really of no use at all to Mike.
mike_bike_kite
Posts: 98
Joined: Tue Jul 26, 2011 12:18 am
Location: London

Re: Opening books?

Post by mike_bike_kite »

I managed to get the opening stuff working using the move strings I favoured. It will now always favour a move in it's opening book rather than one it's calculated. I noticed a couple of things which I thought I'd mention.

1) Psychologically when you see the program reply instantly with a move from the book then you instantly try to get it out of the book. However if I put a small delay into this part of the code then the user is much happier to continue along the standard opening line.

2) It doesn't matter how many openings you have - there aren't enough. I copied listings of openings from various chess pages. I figured 100 would be enough - but it still needs more variation. I'll probably settle on 300.

3) The openings listed on web pages are not very accurate. Out of the 100 I copied from 3 different sources I (actually the program) found around 10 mistakes.
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: Opening books?

Post by Don »

If you PM me I will send you a 10 ply deep set of positions that we use for testing - it has 43,862 lines - so you can play engine vs engine up to 87724 games. I also have a 368,500 line book which is much lower quality and a 3,785 line book. It's all in a simple long algebraic format in a text file that looks like this:

Code: Select all

d2d4 d7d5 c2c4 d5c4 g1f3 g8f6 b1c3 a7a6 e2e4 b7b5
e2e4 e7e6 d2d4 c7c5 g1f3 c5d4 f3d4 a7a6 b1c3 d8c7
d2d4 d7d5 c2c4 c7c6 b1c3 g8f6 g1f3 e7e6 d1d3 d5c4
e2e4 e7e5 g1f3 b8c6 f1c4 g8f6 e1g1 f6e4 c4d5 e4f6
e2e4 e7e5 g1f3 b8c6 f1c4 g8f6 d2d3 f8e7 b1c3 e8g8
g1f3 g8f6 c2c4 e7e6 b1c3 c7c5 e2e4 d7d6 d2d4 c5d4
e2e4 d7d6 d2d4 g7g6 b1c3 f8g7 f1e2 c7c6 h2h4 d8b6
PM me if you are interested.

Don



mike_bike_kite wrote:Thanks for the suggestions guys. Must admit I'm quite confused by the approach taken though and hope you might be able to enlighten me. I imagined the opening book would just be a list of moves with an associated name. The program would then just match current moves (if any) to the available openings and, if it has any matches, pick one and just play the next move. So if the program opened d4 and the opponent replied Nf6 then it could pick from any of the following continuations:

Code: Select all

	static String Openings[] = {
		"d4 Nf6 c4 e6 g3: Catalan Opening",
		"d4 Nf6 Nf3 e6 Bg5: Torre Attack",
		"d4 Nf6 c4 c5 d5 b5: Benko Gambit",
		"d4 Nf6 c4 c5 d5 e6: Benoni Defense",
The code supplied seems to store the openings in an unreadable (by human eyes) and I just can't see why. There's no speed advantage and if one opening proves unsuitable for your program then you'd have a devil of a job to find and delete the opening. You also don't get a nice opening name to show the user.

So why is it done in this fashion?

Code: Select all

const uint64 Random64[781] = {
   U64(0x9D39247E33776D41), U64(0x2AF7398005AAA5C7), 
U64(0x44DB015024623547), U64(0x9C15F73E62A76AE2),
...
Perhaps it stops the really determined opponent from looking at the source code to find what openings it's missing?
mike_bike_kite
Posts: 98
Joined: Tue Jul 26, 2011 12:18 am
Location: London

Re: Opening books?

Post by mike_bike_kite »

That's very kind of you Don. Unfortunately I'm really only using the opening book just to vary my engine's play and I'm also limited by the size of my program as it's an applet ie it's called up in a browser window.
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: Opening books?

Post by Don »

mike_bike_kite wrote:That's very kind of you Don. Unfortunately I'm really only using the opening book just to vary my engine's play and I'm also limited by the size of my program as it's an applet ie it's called up in a browser window.
What you probably need is a very shallow, very wide book.
PK
Posts: 893
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: Opening books?

Post by PK »

as for storing moves vs positions actually there is a middle of the road approach: an initialization function transforming a (small) text book into a set of positions. basically at program startup You call a function book_addline(e2e4 e7e5 g1f3 b8c6) with all the lines needed. (a better format is with a - sign after a move instead of a space that means "never play it")

if You wish, I may send You a set of 980 such lines
mike_bike_kite
Posts: 98
Joined: Tue Jul 26, 2011 12:18 am
Location: London

Re: Opening books?

Post by mike_bike_kite »

Pawel : that would fit quite easily into my code. I would like a copy of that if you don't mind. Thank you.
PK
Posts: 893
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: Opening books?

Post by PK »

You got 2 pm's (via talkchess) containing that little book. It's been the book of my first program (Hopeless) for quite some time, and even now Glass uses it as a hard-coded fallback option when no external book is found.