Page 1 of 1

Probing example code or data structure

Posted: Sat Jan 09, 2010 10:41 pm
by forsslund
Hi,
I'm new to interfacing with the standard EGTB files, and I have tried to find information on how they (Nalimove) actually are structured but could not find any good source on that.
What i'm actually looking for as a start is a command line interface to just probe a (one) position. Maybe that is possible through scid or crafty?
If it is proprietary, are there any other emerging open file format that has good compression that we should use?

Re: Probing example code or data structure

Posted: Mon Jan 11, 2010 9:37 pm
by dann corbit
To use the Nalimov tablebase files, you have to get permission first.
It is also problematic as far as licence (e.g. it cannot be used in GPL projects, for example).

Miguel Ballicora's format is the wave of the future. It will be released with a licence that everyone can use. Every other format is a pest (for some reason)*.

* as far as I am concerned
IMO-YMMV

Re: Probing example code or data structure

Posted: Sun Jan 23, 2011 4:47 pm
by Ed Trice
forsslund wrote:Hi,
I'm new to interfacing with the standard EGTB files, and I have tried to find information on how they (Nalimove) actually are structured but could not find any good source on that.
What i'm actually looking for as a start is a command line interface to just probe a (one) position. Maybe that is possible through scid or crafty?
If it is proprietary, are there any other emerging open file format that has good compression that we should use?
There are command line interface prefixes to set up a FEN position, including side to move and so on, and then query the database to get the distance to mate info (or draw).

I can look them up for you and report back.

Re: Probing example code or data structure

Posted: Sun Jan 23, 2011 4:57 pm
by Ed Trice
Ok here is what I found.

1. Locate a copy of the tbgen program that generates any tablebases using his format.
2. Say you are examining king + rook + pawn vs. king + rook; make sure you have that file in the same directory as the executable.
3. Maybe you need to "hunt" for a few positions with a certain DTW. The longest is 74 moves in that endgame, so you type in:

Code: Select all

tbgen -w+74 krpkr
...into the console app, and it will spit out:

Code: Select all

Scanning krpkr wtm for win in 74

k7/8/8/8/8/4R3/6P1/1K5r w - -

33 positions found
You can save the FEN positions to a file for later examination by a program with a GUI that can probe the tablebases, or do it the hard way with the command line interface.

There are also many other handy features embedded into the tbgen program.

For what positions of the white king can black to move hold the draw? It seems like a complex question, and one you might not expect the program to be able to handle.

But you can get the answer from a position fragment (white king missing) like this:

Code: Select all

8 R . . . . . . .
7 . . . . . . k .
6 P . . . . . . .
5 . . . . . . . .
4 . . . . . . . .
3 . . . . . . . .
2 . . . . . . . .
1 r . . . . . . .
The tbgen program can output a "drawing zone" with this command:

Code: Select all

tbgen -r b bd "kg7 ra1 Ra8 Pa6 zone(K)" krpkr
It will then spit out this:

Code: Select all

8 . . . . . . . .
7 . . . . . . . .
6 . . . . 1 . . .
5 . . . . . 1 1 1
4 . . . . . 1 1 1
3 . . . . 1 1 1 1
2 . . . 1 1 1 1 1
1 . . . . . . . .
All of the positions of the white king where black to move can draw are marked by a number 1.