Syzygy bases from memory

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Syzygy bases from memory

Post by Rebel »

I want to fix some holes in my static KPvK evaluation from the 80's. It catches most (80-90%) of the winning positions but not all. Installing the Syzygy bases is of course the most simple solution but it is slow because it runs from HD. The question is if it can run from memory and if loading "KPvK.rtbw" and "KPvK.rtbz" at program start is sufficient.
90% of coding is debugging, the other 10% is writing bugs.
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Syzygy bases from memory

Post by mvanthoor »

Rebel wrote: Wed Jun 16, 2021 11:22 am I want to fix some holes in my static KPvK evaluation from the 80's. It catches most (80-90%) of the winning positions but not all. Installing the Syzygy bases is of course the most simple solution but it is slow because it runs from HD. The question is if it can run from memory and if loading "KPvK.rtbw" and "KPvK.rtbz" at program start is sufficient.
You could create a RAM-drive. When the computer starts, you create the RAM-drive. Hook up a batch file in the Windows Scheduler (with a delayed start) to unzip a ZIP-file containing the TB's onto the RAM-drive. Even on my 5 year old computer, unzipping the TB's on an SSD (also 5 years old) takes less than 10 seconds. So it'll slow down your computer's boot sequence with about 10 seconds and it'll take 1 GB of RAM.

(If I really wanted my TB's in memory, both wouldn't be an issue for me, because this system has 32GB RAM and boots in under a minute as it is now. The most time-consuming part of the process is actually booting the UEFI and having it run its checks.)
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: Syzygy bases from memory

Post by xr_a_y »

User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: Syzygy bases from memory

Post by Rebel »

mvanthoor wrote: Wed Jun 16, 2021 11:35 am
Rebel wrote: Wed Jun 16, 2021 11:22 am I want to fix some holes in my static KPvK evaluation from the 80's. It catches most (80-90%) of the winning positions but not all. Installing the Syzygy bases is of course the most simple solution but it is slow because it runs from HD. The question is if it can run from memory and if loading "KPvK.rtbw" and "KPvK.rtbz" at program start is sufficient.
You could create a RAM-drive. When the computer starts, you create the RAM-drive. Hook up a batch file in the Windows Scheduler (with a delayed start) to unzip a ZIP-file containing the TB's onto the RAM-drive. Even on my 5 year old computer, unzipping the TB's on an SSD (also 5 years old) takes less than 10 seconds. So it'll slow down your computer's boot sequence with about 10 seconds and it'll take 1 GB of RAM.

(If I really wanted my TB's in memory, both wouldn't be an issue for me, because this system has 32GB RAM and boots in under a minute as it is now. The most time-consuming part of the process is actually booting the UEFI and having it run its checks.)
That's an elegant solution.
90% of coding is debugging, the other 10% is writing bugs.
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: Syzygy bases from memory

Post by Rebel »

xr_a_y wrote: Wed Jun 16, 2021 11:55 am Why not build just the exact KPK table on the fly ?

http://talkchess.com/forum3/viewtopic.p ... 57#p511740

Done in Minic here for instance : https://github.com/tryingsomestuff/Mini ... ce/kpk.hpp and https://github.com/tryingsomestuff/Mini ... ce/kpk.cpp
I wonder how accurate your KPK table is, 100%?

Same for HGM's code.

I am asking (in general) because in the past I have tried KPK C-code from others and there were too many errors.

Also there are the bitbases, for instance in use by slowchess, how accurate are they?
90% of coding is debugging, the other 10% is writing bugs.
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: Syzygy bases from memory

Post by xr_a_y »

Rebel wrote: Wed Jun 16, 2021 1:37 pm
xr_a_y wrote: Wed Jun 16, 2021 11:55 am Why not build just the exact KPK table on the fly ?

http://talkchess.com/forum3/viewtopic.p ... 57#p511740

Done in Minic here for instance : https://github.com/tryingsomestuff/Mini ... ce/kpk.hpp and https://github.com/tryingsomestuff/Mini ... ce/kpk.cpp
I wonder how accurate your KPK table is, 100%?

Same for HGM's code.

I am asking (in general) because in the past I have tried KPK C-code from others and there were too many errors.

Also there are the bitbases, for instance in use by slowchess, how accurate are they?
The thing in Minic should be 100%.
Joost Buijs
Posts: 1563
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: Syzygy bases from memory

Post by Joost Buijs »

You could also take a look at Marcel van Kervinck's KPK EGT generator, as far as I know it should be pretty accurate.

https://github.com/kervinck/pfkpk
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Syzygy bases from memory

Post by mar »

feel free to use mine, Ed. you can grab the table (kpkTable.h) and the probing code in kpk.cpp
my generator code is probably a bit complicated, but I can tell you that the accuracy is 100%
something a bit odd is that I mirror around the pawn, not around the king which is more common :)
the table is around 25kb in memory, precomputed table cost exactly nothing at program startup (generating kpk is very fast though)
https://www.github.com/kmar/cheng4
Martin Sedlak
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Syzygy bases from memory

Post by mvanthoor »

Also, you don't need _all_ the tablebases; if you just want the KP-K tablebases, you could attach those files to the executable and then probe them using a library such as Fathom or Phyrric. (I couldn't tell you how this works in C or C++; never did it. I know Rust can do it, though.)
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: Syzygy bases from memory

Post by Rebel »

Another syzygy question, is there a tool that can create all epd positions from a syzygy file?

For instance, It would be nice to have all winning positions from KRKN or KRKB endings, or the draws of KRKP endings, they are not too many.

Generating KRKP myself (for white & black) resulted in 36 million epd's but only 4.8 million are draws, would be nice to have in my (your) eval, not from slow disc but from fast memory.
90% of coding is debugging, the other 10% is writing bugs.