Author: Andrew Williams
Date: 00:47:51 06/11/99
Go up one level in this thread
On June 10, 1999 at 13:33:47, Ross wrote: >Can someone outline the basic workings of an opening book for a chess program? >what type of things are being determined and considered when the program is >selecting a reply? > >Thanks >Regards >Ross Here is a description of a very naive approach to this. To see how it is done properly, take a look at the latest issue of ICCAJ, where Bob Hyatt describes crafty's book. When I build my (PostModernist's) opening book, I do this: I take a large number of games (I use games from TWIC). I then go through each game. I keep a record of who won the game, then go through each move (usually the first thirty full moves). For every position that occurs in the game, I generate a hash key which will be used as an index into my book. If the position is already in the book, I update the counts for White wins from this position, Black wins from this position or Draws from this position, according to who won the game. If the position isn't yet in the book, I create a new record in my opening book for this position, setting either WhiteWins, BlackWins or Draws to 1, depending on the result of the game. Once I've finished with the game, I get the next game and do this again etc. When this process is finished, I have a big file which has a large number of positions in it. Each position has a record of how many times White won, how many times Black won and how many times the game was drawn after this position arose. Suppose now PostModernist is playing White in a game. For the first move of the game, it looks in the book and finds this: e4 25434 d4 22654 Nf3 16987 c4 12234 g3 etc etc The numbers represent the number of times the position after the move at left has occurred in games where White won or drew. I now just generate a random number to decide which move to make. Of course, you can fiddle with the number in order to achieve a safer approach - you might say that unless White has won or drawn at least as many times as it has lost, the number will be set to zero and the move will never be chosen. Or you might award 3 points for a win and one for a draw when calculating the number, to favour lines which more likely to yield a win. Or you might subtract 1 for every loss, so as to discourage lines which often lead to a loss. etc etc etc This approach is far from perfect and far from complete, but it works OK. Hope this helps. Andrew Williams
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.