bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnubg] Bearoff/Bearin database question


From: Joern Thyssen
Subject: Re: [Bug-gnubg] Bearoff/Bearin database question
Date: Wed, 4 Dec 2002 22:39:36 +0000
User-agent: Mutt/1.4i

On Tue, Dec 03, 2002 at 03:59:53PM -0200, Albert Silver wrote
> Just out of curiosity, how exactly are the positions coded in the
> databases? 

The actual position is not stored in the database. THe positions are
just enumerated in a convinient way, for example, one-sided bearoff with
15 chequers on 6 points:

Position#       Position 
   0            zero chequers
   1            1 chequer on the ace point
   2            1 chequer on the deuce point
   3            1 chequer on the 3 point
   ...
   6            1 chequer on the 6 point
   7            2 chequers on the ace point
   8            1 chequer on both the ace and deuce point
54623           15 chequers on the 6 point

Two-sided databases are similar exact that the position# is calculated
as:

position# = position#(player 0) * number of one sided positions +
            position#(player 1)

For two-sided bearoff databases we store 8 bytes of data (4 numbers of 2
bytes each). To find the equity of position# 10000, I just seek to
byte 80000 in the file and read 8 bytes. The 8 bytes of data can be
transformed into the cubeless and cubeful equities for that position.

For one-sided bearoff databases it's a bit more complicated since we do
not store the same number of bytes for every position (min 4 bytes and
max 128 bytes, average is 19 bytes for the 6 point database). In the
beginning of the file there is an table that gives the offset for each
position, so the algorithm is:

find bearoff distribution for position# 10000:

seek to byte 80000 in the file
read 8 bytes with offsets and other goodies
seek to the byte calculated from the offset
read a number of bytes calculated from "the other goodies"
transform the data read into bearoff and gammon distributions

Jørn




reply via email to

[Prev in Thread] Current Thread [Next in Thread]