KPK
Moderator: Ras
-
- Posts: 7296
- Joined: Thu Aug 18, 2011 12:04 pm
- Full name: Ed Schröder
KPK
In eval I have coded the KPK ending. Now I read on the CPW of a 12Kb bitbase file that has all the positions pre-calculated. It does not offer a download. Where can I get it? Would like to throw out my code and replace it with a table look-up.
-
- Posts: 3241
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: KPK
Stockfish computes the KPK bitbase on the fly, when the program starts:Rebel wrote:In eval I have coded the KPK ending. Now I read on the CPW of a 12Kb bitbase file that has all the positions pre-calculated. It does not offer a download. Where can I get it? Would like to throw out my code and replace it with a table look-up.
https://github.com/mcostalba/Stockfish/ ... itbase.cpp
If your engine is GPL, you can simply copy/paste this code (adapting it of course). That's what I did in DiscoCheck, because I really couldn't be bothered to reinvent the KPK wheel.
If not, you can make a trivial modification to Stockfish, and make it spit out the bitbase into a file. Then if you just use that file, and no source code from SF, I guess that's ok GPL-wise ?
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
-
- Posts: 28331
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: KPK
As you are probably not GPL, and already have a fully original version of the necessary eval code, you can just make a triply-nested loop that scans over all KPK positions and applies your eval to it to decide if the corresponding bit should be set or cleared, and run it at startup to create the table and write it to file, if you could not read it from file.
-
- Posts: 2646
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: KPK
Well, I too calculated the table. A very simple retrograde analysis. I didn't even bother with better indexing - simply used 64*64*48*2 indices, a 48k table.
It was actually pretty fun and creative - in the middle of elo hunting.
What is good that you only need to store one bit for kpk (draw bit).
Safe promotions to queen are considered a win, stalemate or pawn captures are considered draws, invalid positions ignored.
What bothered me however was that there were some "unsolved" positions when the iteration was finished.
I marked them as draws assuming they would result from draw by repetition.
I'm not sure whether that assumption holds however.
But it worked very well for me.
It was actually pretty fun and creative - in the middle of elo hunting.
What is good that you only need to store one bit for kpk (draw bit).
Safe promotions to queen are considered a win, stalemate or pawn captures are considered draws, invalid positions ignored.
What bothered me however was that there were some "unsolved" positions when the iteration was finished.
I marked them as draws assuming they would result from draw by repetition.
I'm not sure whether that assumption holds however.
But it worked very well for me.
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: KPK
This is included in several engines. I can't quote which ones, but on my cluster, I use Fruit, Toga, Arasan, glaurung and stockfish regularly, and at least one of those includes the KPK bit base.Rebel wrote:In eval I have coded the KPK ending. Now I read on the CPW of a 12Kb bitbase file that has all the positions pre-calculated. It does not offer a download. Where can I get it? Would like to throw out my code and replace it with a table look-up.
Personally, I think the rules for this are easy enough to code...
-
- Posts: 28331
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: KPK
I suppose you do test for stalemate after the promotion, not just for recapture of the Queen. Having a Queen and the move is always a win.mar wrote:Safe promotions to queen are considered a win,
That is normal in EGTB generation. Everything that remains after you found all the wins must be draws.What bothered me however was that there were some "unsolved" positions when the iteration was finished.
-
- Posts: 2646
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: KPK
Yes I did. I also checked whether rook underpromotion is safe (no stalemate), in case queen promotion would be stalemate.hgm wrote: I suppose you do test for stalemate after the promotion, not just for recapture of the Queen. Having a Queen and the move is always a win.
Not sure if this is necessary but I didn't want to miss a single special case.
Thanks for clarifying this to me, I always wondered whether it's safe to assume the rest is draw.hgm wrote:That is normal in EGTB generation. Everything that remains after you found all the wins must be draws.What bothered me however was that there were some "unsolved" positions when the iteration was finished.
For KPK one hasn't to worry about en passant, castling rights or index compression/mirroring.
I always wondered however how to calculate proper minimum index set for EGTBs.
Do you do this automatically (as I suspect) or manually for each piece configuration?
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: KPK
Note that there are also few KPK positions where queening draws due to stalemate but underpromoting to a rook wins, e.g.:hgm wrote:I suppose you do test for stalemate after the promotion, not just for recapture of the Queen. Having a Queen and the move is always a win.mar wrote:Safe promotions to queen are considered a win,
[d]8/k1P5/2K5/8/8/8/8/8 w - - 0 1
Sven
-
- Posts: 1154
- Joined: Fri Jun 23, 2006 5:18 am
Re: KPK
Just out of curiosity, are there any where you need to know about under promotion to judge them accurately, or are they all positions where not knowing about under promotion just causes you to mate a few moves later (like this one)?Sven Schüle wrote:Note that there are also few KPK positions where queening draws due to stalemate but underpromoting to a rook wins, e.g.:hgm wrote:I suppose you do test for stalemate after the promotion, not just for recapture of the Queen. Having a Queen and the move is always a win.mar wrote:Safe promotions to queen are considered a win,
[d]8/k1P5/2K5/8/8/8/8/8 w - - 0 1
Sven
-Sam