Convekta Logo
Chess Software Sourcebook
Join Chess Reviews<>
Convekta Logo
[Image]
 
Constructing a player opening book in Chess Assistant 7
keywords: chess assistant, Opening books, Kramnik
Robert Pawlak
Thursday, November 27, 2003

Each opening book can contain multiple direct trees

For a move to be present in the book, it has to be in at least one of the constituent trees

Each move has a point total associated with it

The point total is computed from a weighted set of look up tables

The ctrl-' key combination will show you how the weights are computed

The problem I am going to tackle today is how one goes about making a so-called "personality" opening book. This type of opening book is most commonly used to help the computer simulate the opening play of a particular player. The example I'm going to discuss in this article is that of Vladimir Kramnik. We are going to create a book from elite base, that simulates how he plays.

First, I must make a disclaimer. The book editor in CA is extremely complex. I don't pretend to understand it all. But through a process of trial and error, I've managed to figure out how some things work, and the result is this article. Armed with the knowledge I am about to convey, you should be able to create virtually any type of opening book that you want.

I should also warn you that this article is not for people that are first learning how to use CA. Nor is it applicable for those with CA 6. It will only be helpful to those with CA 7 (the book editor changed drastically from version 6 to 7). Those that know what a direct tree is, and have a little computer background will stand the best chance of understanding how the opening books work.

I should also mention that the CA 7 users manual gives an example of how a book like this can be built. The procedure it discusses is used in many other programs as well. While it is not quite correct, it does have the advantage of being easy to create. The problem is that you end up with a book that mostly plays like Kramnik (about half the time), but also plays like his opponents the other 50% of the time.

Book Editor - Basic Theory of Operation

Take a look at the sidebar for this article. It discusses some very important points about how the CA opening book editor works. Essentially, each move in the book has a point total associated with it. At any particular position in the game, all the points are totaled up for moves leading away from the position, and then each move point total is divided by the grand total of points for all the moves to get the probability that a move will be played.

That probably sounded a little like double-speak. Let's take a practical example. First, suppose that the point totals for the first move are as follows:

e4  10pts, d4 10 pts, c4 20 pts                  Grand point total=40 pts=10+10+20

The probability that the move e4 would be played is 10/40=1/4=25%.  So e4 will be played one out of every four games.

Those of you that are not asleep are probably asking yourself where the points come from.. The answer is not simple, and requires a little discussion.

How Point Totals are Computed for Each Move

Each opening book has a number of columns in it. These columns determine how move point totals are computed. Each column can be of one of four types: Success, Statistics, Comment, or Evaluation. Each column also has a direct tree associated with it. The column type determines how points are computed for the data in the associated direct tree.

A practical example would probably help at this point. What I have done is construct an opening book to simulate Vladimir Kramnik's play. I derived this book from the games in Elite base, which is installed by default. Because of the way the CA book works, I had to build two direct trees. In the first tree, I put all the games that Kramnik played as white. In the second, I placed all the games he played as black.

What I then did was construct a custom book based on these two trees. You can download this book here. This custom book only contains two columns, with each column referring to one of the direct trees that I created. Note that the opening book installed with CA by default (called "guru") contains oodles of columns. I won't even attempt to explain it, since it does not make a good teaching example. So let's go back to the Kramnik book.

[Opening book settings]

After you've downloaded the file, extract the archive into the books subdirectory in your CA 7 root installation directory. Then open up the opening tree window in CA (open it using the "Trees" button). Then click on the three ellipses to the right of the current book name in the opening book window. The tree properties dialog should then appear on your screen. Using the tooltips, find the button for importing configurations, and click it. Then navigate to the folder that extracted the book files in, and select the downloaded book (kramnik.obc).

You should see the Kramnik book appear in your configuration pane. Select it. You should see two rows of entries in the pane to your right (see picture). Each row corresponds to one column in the opening book window. The only remaining thing that you need to do now is make sure that the columns refer to the proper path names for the direct trees. So double click on each pathname, and make sure that it points to either the white kramnik direct tree, or the black kramnik direct tree (in the picture, this would mean clicking on each entry in the path column)..

Ok, now the important thing to understand is that each column has a point total associated with it. In other words:

Point total for move= Weighted Sum of point totals for all columns for that move

[Opening book lookup table]

How are the points computed for each column? I'm glad you asked! Points for each column are computed from lookup tables that can be entered into the book editor. The lookup tables map a particular number (like the number of games played with a particular move) into points. To make the Kramnik book, I had to create two custom lookup tables to do what I wanted. You can view them if you go back to the tree properties window, and click on the "Options" tab. Then click on the "Table of values" button, then select either white or black from the drop-down menu. You should see something like the screenshot to the right

Like I said previously, each lookup table maps one number to another. You will notice that there are four lookup tables that are used (Eval, Success, Count, and Comment), depending on the type of column that is being used. generally, these make sense when you think about it. For example, if the column data contains move comments, then the comment lookup table is used for point computation. The only column that may not be intuitive is the success column. Points are computed for the success column based on the contents of the "Success" and "Count" tables. The formula used here is as follows:

Points for Success Column=Points from Count Lookup*Success Points from Lookup*Column weight

Statistics columns do not use any of the tables. So point totals for statistics columns are computed as follows:

Points for Statistics Column=Number of games played*Column Weight

Like I said before, it might be easier to look at the Kramnik opening book, it might help you understand the procedure. In the Kramnik book, I had to employ a neat little  trick. CA can use a different point total depending upon the current side to move. That is, one table can be used when it's black's turn, and another can be used when it's white's turn. But unfortunately, you can't do this for game occurrence statistics. Otherwise, constructing the Kramnik book would be a lot easier.

Since I knew the formula for computing the success column points, I selected four lookup tables to simulate the behavior I was looking for. So, I set up the "Success" table for white to assign one point if white scored anything but 0% with a particular move. Then I set the count table to be equal to the number of games played with that move. So, for example, if we refer back to the formula I gave previously, and assume that white scores 50% for a particular move, and that move is played in 30 games, and the column weight is 1, the points for the success column would be: 1*30*1=30. Now, the only problem with this approach is that the opening book will not play moves that score 0% (unless all moves score 0% at some particular node in the tree, in which case a move with 0 probability in the book may be played, since the engine takes over).

The completed opening book
[book]

Then I did something similar for black, only I used the tree I constructed for Kramnik playing black for that column. I should also mention at this point, that there is a keyboard sequence (ctrl-'). It will show how the column values are computed for your opening book, and tell you how the point totals were arrived at. Make sure you refresh your browser window when you use it. Otherwise, it won't update the information.

Ok, let's go through the weight computation for Kramnik's move after 1.c4 by white. If we look at the picture for the completed opening book (see above), we get the following important details: From the black tree, only the moves ...c5, ...g6 and ...e6 have been played by Kramnik (in elite base).None of the other moves in the tree have been played by him, so the computer should not play these moves when playing black. If we look at the point total computations for the first move by black we see the following:

[point totals]

The point totals for #black and # white should always be zero, since the weights assigned for those columns are zero (see first graphic for column weights). Then, the success columns all have a weight of 1. The point total for each move is

success table lookup value *  count value from lookup table * column weight

Furthermore, we know that:

The total number of points is 53+0+3=56. For ...c5 53/56=95%, and for ...c6, 3/56=5%. Remember that there are separate lookup tables for white and black to move, and these are set so that the Kramnik direct tree for black is only used when it is black to play.

The whole thing is quite a bit harder to explain than to do. I would recommend that you take a very close look at the Kramnik opening book. It should provide you with a number of clues. Eventually, I am quite sure that the light bulb will go off, and you will begin to understand how the opening book works. In fact, if you've gotten this far in the article, you probably deserve a special prize ;-)

Conclusion

In this article, I discussed a procedure for constructing a player opening book, and discussed the general theory of operation of the book in CA. All CA opening books consist of multiple direct trees. Formulas are used to form point totals for all the moves in the trees. Weighted sums of point totals are then used to compute the probability that a particular move will be played.







ChessAssistant is a trademark of ChessOK
Syndication available through rss.xml
Click on my name to send me e-mail (must have javascript on)