A|H pawn && wrong bishop v K

Discussion of chess software programming and technical issues.

Moderator: Ras

op12no2
Posts: 550
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: A|H pawn && wrong bishop v K

Post by op12no2 »

But you have the right bishop in that scenario - if you change it to black it's a draw according to Hiarcs endgame database...

Edit - Ah you changed it. Yes Hiarcs says white win now. Bugger! Need to add white king position into it.

Thank you.
Last edited by op12no2 on Tue Sep 22, 2015 11:47 am, edited 1 time in total.
User avatar
hgm
Posts: 28361
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: A|H pawn && wrong bishop v K

Post by hgm »

Sorry, I was still editing it. Fruit sees a mate in this position.
op12no2
Posts: 550
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: A|H pawn && wrong bishop v K

Post by op12no2 »

Yes, you're right. Not as simple as I thought...
Ferdy
Posts: 4848
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: A|H pawn && wrong bishop v K

Post by Ferdy »

Here is my basic heuristics used in Deuterium. The defending king should be 0 or 1 unit distance away from the promote square.
The promote sq is at a8. The black king in the diag, should be either in a7 or a8 or b7 or b8. When black king is at a8 sq, the distance is 0 otherwise its distance to a8 is 1, i.e if black king is a7, b7, b8.
[d]8/k7/8/P1K5/5B2/8/8/8 w - - 0 1
User avatar
hgm
Posts: 28361
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: A|H pawn && wrong bishop v K

Post by hgm »

Indeed, this is what I do now too. But it is a bit conservative; there are many positions that could be recognized earlier. Namely where the black King would arrive at the promotion square 3 ply before the white King and 3 ply before the Pawn.
Ferdy
Posts: 4848
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: A|H pawn && wrong bishop v K

Post by Ferdy »

Agreed there are things that someone can add when the defending king is not close to that promotion sq. This is why I call it basic for quick implementation.
User avatar
hgm
Posts: 28361
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: A|H pawn && wrong bishop v K

Post by hgm »

What positions do you recognize as draw in KQKP? This is one I haven't implemented yet. I suppose it is basically all positions where the defending King covers the promotion square, and for c/f Pawns also where it is in the corner, as long as the Queen cannot step in front of the Pawn. I guess you need that one only when the Queen is a Knight jump away from the corner.

The tricky thing is to know how close the attacking King can be before it is lost. I suppose that for c/f Pawns it matters if you are defending on the short or long side of the Pawn, as on the long side you would be drive in front of the Pawn at least once, giving him the opportunity to get one step closer.
kbhearn
Posts: 411
Joined: Thu Dec 30, 2010 4:48 am

Re: A|H pawn && wrong bishop v K

Post by kbhearn »

hgm wrote:What positions do you recognize as draw in KQKP? This is one I haven't implemented yet. I suppose it is basically all positions where the defending King covers the promotion square, and for c/f Pawns also where it is in the corner, as long as the Queen cannot step in front of the Pawn. I guess you need that one only when the Queen is a Knight jump away from the corner.

The tricky thing is to know how close the attacking King can be before it is lost. I suppose that for c/f Pawns it matters if you are defending on the short or long side of the Pawn, as on the long side you would be drive in front of the Pawn at least once, giving him the opportunity to get one step closer.
Depends what % correct you want to be. if you can accept both some false-draws and false-wins that take a couple ply of search to resolve correctly the rules for that are pretty well codified in books. i.e. the win zone for an a-pawn with white to move:

[d]5Q2/8/8/KKKK4/KKKKK3/3KK3/pk1KK3/3KK3 w - - 0 1

the problem would of course be that there are mild exceptions to the rule where the white king can enter the zone with a discovered check and win

The two similar win zones for the c-pawn (depending on defending king short-side or long-side)

[d]5Q2/8/8/8/KKK5/3KK3/1kpKK3/4K3 w - - 0 1

[d]5Q2/8/8/KKKK4/KKKKKKK1/KK3KK1/KKpk1KK1/K4KK1 w - - 0 1
op12no2
Posts: 550
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: A|H pawn && wrong bishop v K

Post by op12no2 »

HGM: Indeed, this is what I do now too. But it is a bit conservative; there are many positions that could be recognized earlier. Namely where the black King would arrive at the promotion square 3 ply before the white King and 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B: IF YOU CLICK ANALYSE IT USES RESOURCES ON YOUR MACHINE NOT A SERVER

Which makes me think search is broken...!
Last edited by op12no2 on Tue Sep 22, 2015 10:07 pm, edited 4 times in total.
Ferdy
Posts: 4848
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: A|H pawn && wrong bishop v K

Post by Ferdy »

hgm wrote:What positions do you recognize as draw in KQKP? This is one I haven't implemented yet.
I only have a/h pawn and c/f pawn. For other files, the Q usually wins and I don't implement them.

I have this book as a guide for kqkp bishop-pawns.
For defending king on right side, meaning the king is close to rook file, the offensive king must be 1 distance away from a specific squares in order to win.
In the diagram (black to move) black wins because its king is close to one of the squares marked with 1.

Image


When the defending king is on the wrong side a distance of 2 squares from offensive king to specific squares marked 2, is enough to win the game. Black to move.

Image

Pawns on rook files are also described in similar method of square numbering in the book.

Book ref.
100 Endgames You Must Know by Jesus de la Villa
Third Edition, New In Chess 2012.