advanced krkp function

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

PK
Posts: 893
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: advanced krkp function

Post by PK »

IMHO some level of basic endgame understanding is necessary even if it does not bring immediate Elo gain. And I agree it must be done starting from the most basic cases and without holes. Even King + minor vs King + minor needs a complementary clause that King + minor doesn't win against king + pawn.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: advanced krkp function

Post by Lyudmil Tsvetkov »

how is it possible to have 16 closing braces after the last else?
so far, whenever I do more than 3 nests, the compiler starts complaining.

a translation from Catalan to Basque seems fine, what I have ascertained however is that it is much better to have non-obfuscated code with no comments, rather than obfuscated one(name mangling) with a lot of comments.
Joerg Oster
Posts: 937
Joined: Fri Mar 10, 2006 4:29 pm
Location: Germany

Re: advanced krkp function

Post by Joerg Oster »

cdani wrote:
hgm wrote: How important is it really to go into so much detail? When I was doing KPK evaluation in KingSlayer, I noticed that the only important thing is really to recognize some certain-draw positions, where it would take very long for the draw to become apparent. Positions where a draw is achieved quickly, e.g. because of stalemate or because the Pawn gets lost, are found very quickly by the search.
Sorry, I didn't saw the rest of your message, or maybe was not there when I first answered.

Really not important in most cases as you tell. I have done it more for fun than for anything else. Anyway should be a bit better than a basic function, but probably not really measurable in elo.

I have done also the KNPK (yes, against a lone king). Contrary to what one can think at first, is full of draws. Is bigger than this one, over 2000 lines of code :-) due to that the exceptions are very common but more sparse, and difficult to grab a lot of them in a few instructions, so often it compares against little local (local to the "if") databases of positions such exceptions. Maybe I will publish it when I clean a little. Of course it solves the typical a7 pawn a8 wk c7/c8 bk that is draw due to the inability of the knight to win tempos, this with a few if's.
Hi Daniel,

that's quite interesting.
Of course, if the defending king is able to capture the pawn, it's a draw.
But search should figure this out very quickly.

Apart from that, only 2 positions are mentioned in 'Fundamental Chess Endings' by Müller/Lamprecht.

Position 1
[d]k7/P7/8/1NK5/8/8/8/8 w - - 0 1

Position 2
[d]K1k5/P7/8/8/8/8/8/7N w - - 0 1

The first position is already recognized by Stockfish, the second one was added by me here: https://github.com/joergoster/Stockfish ... faa0425b8c

Do you have some other positions that needs to be recognized?
Jörg Oster
Henk
Posts: 7217
Joined: Mon May 27, 2013 10:31 am

Re: advanced krkp function

Post by Henk »

Wait until Sven has rewritten it. If this would be normal code ... help!
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: advanced krkp function

Post by cdani »

Lyudmil Tsvetkov wrote:how is it possible to have 16 closing braces after the last else?
so far, whenever I do more than 3 nests, the compiler starts complaining.
Should not happen. The compilers have support more than this.
Henk wrote:Wait until Sven has rewritten it. If this would be normal code ... help!
This work was long, and I have not spent more time triying to make it readable specially due to the nature of the goal, that once it works is not necessary to change it as each condition resolves some positions without further discussion.
Joerg Oster wrote: Do you have some other positions that needs to be recognized?
Nothing really important that an engine could not solve relative fast, I think, as of course I have not tried most drawn positions with an engine. Was more like doing a puzzle than doing really useful work. I searched a bit and I found this position that requires some more depth on Stockfish to be solved, but not much, so nothing special. Probably there are others.
[d]3N4/8/8/8/8/3P4/8/1K2k3 b - - 0 1

[/quote]
Joerg Oster
Posts: 937
Joined: Fri Mar 10, 2006 4:29 pm
Location: Germany

Re: advanced krkp function

Post by Joerg Oster »

This seems to be safe to leave it up to the search to resolve. Thanks.
Jörg Oster
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: advanced krkp function

Post by Ras »

cdani wrote:This work was long, and I have not spent more time triying to make it readable
Spending time to make it readable actually saves time because debugging is faster. Plus that you can find errors by review, which is hardly possible for unreadable code. Lack of readability has certainly contributed to how long it took.
once it works is not necessary to change it
It isn't possible to enhance it either, or to port it to another board geometry, or to interface it with a different engine, or to refactor it. You yourself will not be able to understand that code two years from now. In short, it's throw-away-code.

And that's a pity given how much work you put in there.