Scorpio endgame bitbase specs?

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
User avatar
ilari
Posts: 750
Joined: Mon Mar 27, 2006 5:45 pm
Location: Finland
Contact:

Scorpio endgame bitbase specs?

Post by ilari » Tue Dec 02, 2008 12:44 pm

Now that we have a good clear specification of the Polyglot opening book format, I think endgame bitbases should be next.

When testing Sloppy with valgrind I noticed that the Scorpio egbb library leaks a lot of memory. I took a look at the source code, and couldn't understand it well enough due to unorthodox programming practices and lack of documentation. So I became interested in rewriting the whole thing in clean C++, but to do that I'd need to know the file format. Can anyone help me out here?

Edmund
Posts: 668
Joined: Mon Dec 03, 2007 2:01 pm
Location: Barcelona, Spain
Contact:

Re: Scorpio endgame bitbase specs?

Post by Edmund » Tue Dec 02, 2008 3:14 pm

Just had a quick look at the sourcecode .. if you have any more specific questions I will have to look more precisely.

Scorpio bitbases accept 2 types of files .. compressed and uncompressed
For compression the huffman compression is used.

Then, the important question is how each position is indexed.

Therefor the pieces are ordered per piecetype (note: black pieces > white pieces) Board is mirrored and flipped (using symmetry). For the Kings it uses a preindexed table. Furthermore it uses the fact that there is a maximum of 1 piece per square.
eg. a 3 piece endgame KxK (where x != pawn)
p1 = wk
p2 = bk
p3 = x
in case of KKx .. sides are reversed first and afterwards result inverted

Code: Select all

kki = KK_index[p1 * 64 + p2];
p3i = p3 - (p3 > p1) - (p3 > p2);

pos_index = kki * 62 + p3i;
For the case of KPK:
if the pawn is on the left side of the board: flip the board

Code: Select all

if(file64(p3) > FILED) {
p1 = MIRRORF64(p1);
p2 = MIRRORF64(p2);
p3 = MIRRORF64(p3);
}
			
kki = KK_WP_index[p1 * 64 + p2];
p3i = SQ6424(p3);

pos_index = kki * 24 + p3i;
... you can find all this information in static void get_index(...)

how to use this index you find in
int EGBB::get_score(UBMP32 index,PSEARCHER psearcher)
for the uncompressed version:

Code: Select all

score = VALUE[(table[index >> 2] >> (2 * (index & 3))) & 3];

User avatar
ilari
Posts: 750
Joined: Mon Mar 27, 2006 5:45 pm
Location: Finland
Contact:

Re: Scorpio endgame bitbase specs?

Post by ilari » Tue Dec 02, 2008 8:02 pm

Thanks a lot. I'll see how far I can get with this.

Post Reply