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

A|H pawn && wrong bishop v K

Post by op12no2 »

I've noticed that Lozza often finds herself left with a A|H pawn and a bishop of the opposite colour to the promotion square, against a bare King. And thinks she is up when in fact it's a draw and can be evaluated as such.

I'm about to code this in eval, but just wondering if it's a specific case of something more generic; any buzz words/phrases I can search for in the wiki/forums etc...?
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 »

It is one of the infamous cases where the naive evaluation does not work, and which is encountered reasonably often. (Especially against opponents that know about it!) Just like KNNK or KBK. But the latter can be recognized by material composition only, while this one requires you to look where the pieces are.

There is a somewhat similar case in KNPK, when a rook-Pawn is already on 7th rank and the defending King before it. The attacking King can then never protect the Pawn without stalemating you, so the Knight can never move without losing the Pawn to drive you away. But because it requires the Knight and Pawn to be in a very specific place, it is very rare compared to KBPK. One funny thing about this: engines that do not know about under-promotion can lose this, because they sooner or later leave the promotion square unprotected, counting on being stalemated when the opponent promotes to Q. :lol:

Other often encountered end-games where the engine 'reckons itself rich' are the drawn positions in KQKP and KPK. So it also pays to have recognizers for those.
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 »

OK thx HG I'll hardwire it with some twiddly bits for king distance etc. And then look the others you mention.
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 »

I found that it is pretty tricky to recognize any drawn cases other than where the defending King is in front of the Pawn on the rook- or knight file. In particular
[d]8/8/P1k5/B7/8/8/8/7K b

forces you to leave the Pawn's 'square' by zugzwang. And
[d]2k5/8/P7/4B3/8/8/8/7K b

likewise. So you can lose even when you are within the square, and much closer to the promotion square than the attacking King.
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 »

Ah - yes, thanks, not as simple as I thought..
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

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

Post by Sven »

op12no2 wrote:I've noticed that Lozza often finds herself left with a A|H pawn and a bishop of the opposite colour to the promotion square, against a bare King. And thinks she is up when in fact it's a draw and can be evaluated as such.

I'm about to code this in eval, but just wondering if it's a specific case of something more generic; any buzz words/phrases I can search for in the wiki/forums etc...?
The buzz phrase would be "blind bishop". I don't think it's a specific case of something more generic.
mjlef
Posts: 1494
Joined: Thu Mar 30, 2006 2:08 pm

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

Post by mjlef »

op12no2 wrote:I've noticed that Lozza often finds herself left with a A|H pawn and a bishop of the opposite colour to the promotion square, against a bare King. And thinks she is up when in fact it's a draw and can be evaluated as such.

I'm about to code this in eval, but just wondering if it's a specific case of something more generic; any buzz words/phrases I can search for in the wiki/forums etc...?
This is true no matter how many pawns are on the rook file. So you might want to make your conditions general enough to cover that.
xmas79
Posts: 286
Joined: Mon Jun 03, 2013 7:05 pm
Location: Italy

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

Post by xmas79 »

When I wanted to code some endgame knowledge in my engine, I remember someone gave me a list of known endgames. There were positions drawn and won, and some were pretty crazy.... I remember this one [d]8/8/8/n7/R5K1/8/8/k7 b - -
and the others were along this wave length.... Well, even before trying to write any single line of code I resigned, because there were too much variations on the theme, and I thought it would not worth the effort... Since it's very hard to evaluate correctly all these positions, I preferred the easier route of recognizing the known draw positions (eg KBPk with bishop wrong corner color and king already in the corner) and let the search do the rest by scaling down the (winning) score down to around 50cp... If the engine can promote the pawn, well, it will see the score jump and will win the game. However, landing in such positions in qsearch at hight depths will lead to errors, because the engine will not have the time to figure out (with search) the real game outcome.... but at least your engine will keep on trying to win... Or at least this is how I think it is when the engine has advantage.... On the other hand, it will lead to a disaster if the position of the engine is lost (eg the bare king) because it will see a score jump from -4.00 up to -0.50 and will of course take that route.........
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 »

Thanks for the replies. I did a quick experiment by adding an else clause to unstoppable passers:-

Code: Select all

else if (numPieces == 4 && wNumBishops && wNumPawns && bKingRank > rank) {
  if (file == 1 && wBBishop && (bKingFile == 1 || bKingFile == 2))
    return CONTEMPT;
  if (file == 8 && wWBishop && (bKingFile == 7 || bKingFile == 8))
    return CONTEMPT;
}
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 »

When the white King can keep you away from the promotion square it is also lost:

[d]8/K7/8/8/kB6/P7/8/8 w - -- 0 1

[d]6K1/8/5k2/8/1B6/P7/8/8 w - -- 0 1
Last edited by hgm on Tue Sep 22, 2015 11:45 am, edited 2 times in total.