| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Fixed values
|
When the
opening book is created
, it is by loading games in PGN-format. Together
with each move the sum of all the results for that move is stored. These figures are
not changed unless we merge in more games to the book .
|
|
Dynamic values
|
When a game is over Terra will go through all the selected book moves in the game
and update the result for each of the positions. This statistics is based only on
Terra's own results and is changing all the time.
|
|
We can also have
User set values
(i.e. by the bookeval command or move nags like
e4! h6?). When we have User set values, Terra's own results are not stored
and will not have any effect on the Dynamic values.
|
It is possible to have more than one opening book, but Terra can only use one at a time. It is possible
to
merge two books together
into
one.
The PostBook
This is a special book that Terra builds automatically. None of the functions applied to the ordinary book can be used here. Everything is automatic with the post book.
When the book line ends Terra has to start ordinary searching. The first about 10 moves after being
out of book is Terra keeping track
of. Depending of the evaluations and the game score, Terra is saving statistics together with these
moves. In a way Terra is expanding
it's book with this method. The PostBook format is not the same as the book format and the two are kept
apart. The PostBook has the
default name postbook.dat and is an ASCII-file in the Book directory. The name can be changed in Terra.ini
or with the command
Postfile filename. When upgrading Terra or after changing opening books, it is probably best
to just delete postbook.dat. A new
postbook will be build up by Terra.
If you get troubles with the postbook, just delete it.
When loading the PGN-file Terra uses the memory available for the hash tables. In order to get the book
creation process as fast as
possible, set the
hash table size
as large as possible.
The Post Book
The Post book is completely handled by Terra itself. The only thing you can do is to delete it. It is possible to edit this ASCII-file but then you have to have detailed knowledge about the format.
Start Terra and run the command createbook xxxx yyyy.pgn s t where xxxx is the book file, yyyy.pgn is the PGN-file, s is number of half moves in the PGN file that at most will be used and t is the minimum number of games that the move has to be in (otherwise it will not be included in the book)
|
Changing the
Dynamic statistics
|
It is possible to change this statistics manually, by commands or by moves with nags. The purpose is
to
control the opening lines by hand. The command to use is
Bookeval
. In fact it is possible to collect all
the commands in a
command file
and run the whole batch.
|
|
Add more games
|
It is possible to expand an existing book by
adding another PGN-file
.
|
Changing the Dynamic statistics with the command BookEval
It is possible to manually control what moves in the Book Terra will select. The command is Bookeval. First make the moves including the move you want to set a value for. Now set your own value with Bookeval xxxx where xxxx is either a value between 0-100, clear or one of !,?,!!, !? or ?!.
The translation is:
|
cmd
|
Value
|
Meaning
|
|
?
|
0
|
never play this move.
|
|
!?
|
15
|
very seldom play this move.
|
|
!
|
75
|
very often play this move.
|
|
!!
|
100
|
always play this move. If there are more than one such move a random selection will take
place.
|
|
clear
|
-
|
Clear all User set values or Terra statistics for this move.
|
By giving numbers instead of signs you can fine tune it a bit.
In the position preceding the actual move (command undo) you can look at all moves and values
with commands
Bstat or Bmoves
.
Changing the Dynamic statistics with moves and nags
It is possible to set your own values for a certain move by keeping a PGN-file with lines and moves that you want to control.
The same table as above is valid, except from the clear command and the fact that you can give numbers in the BookEval command.
Such a PGN-file could look like:
[Event: "Line 1"] 1. e4!! c6!? 2.d4!! [Event: "Line 2"] 1. d4!! Nf6! 2. c4! d6! [Event: "Line 3"] 1. d4 d5! 2. c4 a6?
You will need at least one tag (in this case the Event tag) in order to separate the lines from each other. You can use whatever tag you want.i.e. [Result 1-0] or [Date: "2001-01-01"] etc.
This file says that:
Note that 1.d4 had no nags in "Line 3" and the last nag was !! which will be used. If we have conflicting nags i.e. one line with 1.f4! and later on 1.f4? the last found nag in the file will be used.
Just run the command BookFile file or set BookFile=file in terra.ini , where file is the Book file to use. In Both ways it will change to the new book file if there is such a file in the Book directory.
Let's see how Terra will select a move from either the book or the PostBook file.
Terra will handle the group of moves with "User set values" apart from the other moves. In a certain position Terra will first decide from which group to select a move. From the "User set values" group or the other group (if there are moves from both groups of course). In order to select a group we try to evaluate the total weight of all the user set values. Each set value is between 0-100 and represents a weight telling us how often the move is supposed to be selected. v1, v2,....,vn are all these values form move# 1 - n. P = 1 - (100-v1)/100 * (100-v2)/100 *...* (100-vn)/100 gives the probability P that the "User set values" group will be selected this time. If Random(0,100) < (P*100) we will select the "User set values" group otherwise we will select the other one.
The Roulette Wheel method
If the "User set values" group is selected Terra will select the move from this group with the use of the Roulette Wheel method:
Special case
If we have at least one move with a set value = 100, then Terra will select that move without any selection method at all. In fact the method to select between "User set values" group and the other moves would anyway always select "User set values", if we have one or more moves with the value 100.
If there are more than one such move, Terra will randomly select one of these.
In order to select a move from game statistics, we have to take into consideration the settings of RandomType, BookLimit, TerraLim, MinBookGames and MinTerraGames. The BookLimit, TerraLim, MinBookGames and MinTerraGames tell us what moves to just sort out. If RandomType=1 (Terra's Win% + Fixed values frequency), the frequency has to be translated to something comparable with Win%. We do like this:
Each frequency value is translated by 100*f/FSum where f is the frequency and FSum is the sum of all frequencies used.
If RandomType is one of the "select best" choices, we just selects the best value from all moves meeting the settings mentioned above.
If RandomType is one of the random choices we are using the Roulette Wheel method.
See "Selecting from User set values"
Within PostBook Terra saves information about moves outside the book. Depending on the saved information Terra will:
No randomized selection process will take place with PostBook moves.
|
Fixed values
|
Terra values or Set values
|
|||||
|
Move
|
# of games
|
Win%
|
# of games
|
Win%
|
Remark
|
|
e5
|
5783
|
43
|
5
|
60
|
|
|
c5
|
5230
|
48
|
127
|
75
|
Set to often play (=!)
|
|
e6
|
1329
|
36
|
1
|
0
|
|
|
c6
|
748
|
26
|
|||
|
Nf6
|
276
|
27
|
127
|
0
|
Set to never play (=?)
|
|
d5
|
43
|
29
|
127
|
15
|
Set to play seldom (=?!)
|
|
d6
|
21
|
34
|
|||
|
Nc6
|
6
|
48
|
127
|
0
|
Set to never play (=?)
|
|
b6
|
5
|
27
|
|||
|
g6
|
2
|
0
|
|||
|
a6
|
2
|
100
|
Here we have a lot of moves. Some with set values (yellow rows) , some with Terra statistics and some with only the Fixed values. Let's follow the procedure and pick one move. Assume that RandomType=1 (Terra stat + frequency) and BookLimit=33, MinTerraGames=3, TerraLimit=40 and MinBookGames=4
First: Do we have one or more moves with Set value=100 (always select)? No. (Otherwise that move would be selected directly)
Secondly: Compute the probability of using the group of moves with "Set values". Here c5 and d5. (Nf6 and Nc6 are set to never be played) P=75*(100-15)/100 = 63,75. Let's look at two different outcomes of rolling the dice.
1st case) Random(0,100) returns 60, meaning that the "Set values" group is selected.
Now we have c5 and d5 with the values 75 and 15 respectively. Using the Roulette Wheel method: The Sum is 85. Random(0,85) gives S=45. Start by taking the first move by random, say d5. Gives 15. Next move c5 gives total 85 and S is exceeded. The selected move is c5.
2nd case) Random(0,100) returns 70, meaning that the other group of move is selected.
So we have to select a move from the moves e5, e6, c6, d6, b6, g6 and a6.
RandomType=1 tells us to use Terra values if there are any (enough due to MinTerraGames). What do we have now?
|
Move
|
What value to use
|
Why
|
|
e5
|
60
|
5 Terra games > MinTerraGames=3. Use the Terra Win% which exceeds the TerraLimit value
|
|
e6
|
1329
|
Only 1 Terra game says select from fixed values. RandomType=1 says use Frequency
|
|
c6
|
-
|
not selected du to BookLimit=33.
|
|
d6
|
21
|
use Frequency due to RandomType=1
|
|
b6
|
-
|
not selected du to BookLimit=33.
|
|
g6
|
-
|
not selected due to MinBookGames=4
|
|
a6
|
-
|
not selected due to MinBookGames=4
|
Shaded means not selected for some reason.
All the frequency values will be translated: 1329 /(FSum) * 100 = 43 and the others 10, 0.2 (1 will be used) when FSum=13445 giving us this new table:
|
Move
|
What value to use
|
|
e5
|
60
|
|
e6
|
63
|
|
d6
|
1
|
Now select a move with the Roulette Wheel method ....
S = 60+63+1 = 124. S=Random(0,124) Let's say 113.
Randomly pick move after move until 113 is reached or exceeded.
e6: 63 63
d6: 1 64
e5: 60 124 <== Exceeded!
N.B. If the value for e5 had not exceeded the value of TerraLimit the move would be placed into the Avoid List and not selected at all.
How to set the book optionsBooks and learning are so integrated with each other so you'll better look into how to set the learning options .
Learning and booksBook learning is the most used learning scheme for chess programs. Terra has both book learning and post book (after book) learning. The learning function, stores game results and/or the search score together with each move. This is a quite effective way to avoid players trying to win over and over again with the same opening variation. It is more fun to play a program that avoids bad experiences!
Please give your comments in WinBoard Forum or email me. This document was updated 2004-08-02.