Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: How are EGTB files accessed so quickly?

Author: Dieter Buerssner

Date: 06:50:57 03/25/05

Go up one level in this thread


On March 25, 2005 at 08:51:52, Anson T J wrote:

>Does anyone know how they are accessed at such high speeds? Some of the files
>are very large, how does the engine know exactly where to look inside the TB for
>the position of interest without searching the whole database?

The position (in the sense of offest, "the 215th byte") in the database is
calculated from the chess position. A very simplified example, take KR vs. K.
We enumerate the squares on the board from 0 (a1) to 63 (h7). The formula for
the position in the database can be:

offset = square(white K)*64*64 + square(black K)*64 + square(white R)

You should see, that every position gives a different offset. You may also see,
that some offsets don't have any legal position. For example the above formula
reserves offset 0 for all 3 men on a1. Offset 1 would be wK and bK on a1 and wR
on a2 - again no valid position.

This can be avoided by a more sophisticated formula. Also, the symmetry of the
position can be take into account, to reduce the number of stored positions.
Other things, like the fact that there never will be 2 kings on neighboring
squares can be used. But the principle will be the same -> feed the position
into some sort of formula and calculate a unique (and not too huge) offset from
it.

At the calculated offset in the database file, you will find the game
theoretical result of this position. It could be draw, mate in 5, etc. All such
results will be translated to one value of a byte (0 - 256).

Additionally, the whole database can be compressed.

Regards,
Dieter




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.