Good Example of Horizon effect in Eval

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Ross Boyd
Posts: 114
Joined: Wed Mar 08, 2006 9:52 pm
Location: Wollongong, Australia

Good Example of Horizon effect in Eval

Post by Ross Boyd »

A few days ago Steve Maughan and Uri discussed a K+P ending which required knowledge of KPvKQ to solve it. Quote below...

Steve Maughan wrote:
Here a position that's been discussed on Susan Polgar's blog (http://susanpolgar.blogspot.com/2008/01 ... stuff.html)

[D]8/8/7p/2p5/2P1K3/1kP1P3/8/8 w - -

It's a draw. But many of the top engines think that Kf5 wins for white. The engines that seem to have problems are Glaurung 2, Naum 2.2 and Rybka - Shredder and Hiarcs see that it's a draw. It's probably a position where the square of pawns rule breaks down. Anyway I thought it was of interest


Uri replied:

The main problem here is that glaurung does not see that the following is a draw

[D]4Q3/8/8/8/7K/8/1kp5/8 w - - 0 9

Uri
I agree with Uri but when I tested Trace 2 I came up against a fairly common problem... evaluation horizon effect...

T2 understands that Uri's example is drawn - however, she avoids capturing the h pawn so that her KPKQ evaluation doesn't kick in and return a draw. In the original position she scores Kf5 as +6.75 @ 26 ply depth.

Also, mighty Rybka 2.3.2a gets to 25 ply and scores Kf5 as +7.29

Evaluation horizon effect is a pain in the a$$ to solve. If I write a KPPKQ recognizer the same horizon effect will occur when there is KPPPKQ on the board. ... so I have to write a KPPPPKQ ... and so on...

Turn off EGBB and EGTB and see if your engine can solve it.

Any ideas on how to fix this one?

Ross
Harald Johnsen

Re: Good Example of Horizon effect in Eval

Post by Harald Johnsen »

You don't need to 'solve' this kind of position, because if you are there it is too late, the game is drawn so displaying 0 or +7 is not important.
OTOH you don't want to get there so you can add some heuristics in your eval/recognizer :

Code: Select all

if( board[c2] == black pawn )
  score /= 2;
Now your engine won't want to go in a position with a black pawn on c2 if there are other good positions.
Also note that white can only do checks here, so if you handle that in your eval you know that the position is drawn.

Code: Select all

if( a zillion checks at the end of this variation )
  score /= 4;
HJ.
Tony

Re: Good Example of Horizon effect in Eval

Post by Tony »

Harald Johnsen wrote:You don't need to 'solve' this kind of position, because if you are there it is too late, the game is drawn so displaying 0 or +7 is not important.
OTOH you don't want to get there so you can add some heuristics in your eval/recognizer :

Code: Select all

if( board[c2] == black pawn )
  score /= 2;
Now your engine won't want to go in a position with a black pawn on c2 if there are other good positions.
Also note that white can only do checks here, so if you handle that in your eval you know that the position is drawn.

Code: Select all

if( a zillion checks at the end of this variation )
  score /= 4;
HJ.
Yes, now it will be happy with the pawn on c3 and black to move :)

It's not that easy to find general rules, but "pushing" it further away does help. In this case (black pawn on c3) the score will be lower than on c2.

But you were correct, this all only works if there is still the possibility to avoid it.

Tony

PS the "reduce score if a lot of checks" is very dangerous. In some endgames long series of checks always happen (KQPKQP)

Tony
User avatar
hgm
Posts: 27807
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Good Example of Horizon effect in Eval

Post by hgm »

Ross Boyd wrote:T2 understands that Uri's example is drawn - however, she avoids capturing the h pawn so that her KPKQ evaluation doesn't kick in and return a draw. In the original position she scores Kf5 as +6.75 @ 26 ply depth.
I don't get this. After Kf5 black starts running with the Pawn, and the white King can only just step back into its square. So how are you _not_ going to take the h-Pawn? If you don't, it will be a Queen in 8 ply, so how do you ever get +6.75 at 26 ply? Only a branch that prevents black from promoting (or captures the Queen as soon as he does) could have a positive score.

If you want to put in end-game knowledge, the knowledgy you should have is that an a, c, f or h Pawn on the 7th supported by King without the opponent's King near, can only be stopped by sacrificing a Queen. It doesn't matter much if there are other Pawns on the board. If there are, but they are blaocked, it is just as drawn. Even if they have moves, they might not have enough moves.

So you should score the P on 7th supported by King as nearly a Queen, until the contrary can be shown. But you should search on, to try showing it.
Uri Blass
Posts: 10296
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Good Example of Horizon effect in Eval

Post by Uri Blass »

hgm wrote:
Ross Boyd wrote:T2 understands that Uri's example is drawn - however, she avoids capturing the h pawn so that her KPKQ evaluation doesn't kick in and return a draw. In the original position she scores Kf5 as +6.75 @ 26 ply depth.
I don't get this. After Kf5 black starts running with the Pawn, and the white King can only just step back into its square. So how are you _not_ going to take the h-Pawn? If you don't, it will be a Queen in 8 ply, so how do you ever get +6.75 at 26 ply? Only a branch that prevents black from promoting (or captures the Queen as soon as he does) could have a positive score.

If you want to put in end-game knowledge, the knowledgy you should have is that an a, c, f or h Pawn on the 7th supported by King without the opponent's King near, can only be stopped by sacrificing a Queen. It doesn't matter much if there are other Pawns on the board. If there are, but they are blaocked, it is just as drawn. Even if they have moves, they might not have enough moves.

So you should score the P on 7th supported by King as nearly a Queen, until the contrary can be shown. But you should search on, to try showing it.
scoring a P on the 7th as nearly a queen is dangerous because in that case you may score drawn KRP vs KQ as clear advantage for the rook because RP=R+P=almost R+Q

You also may score lost KPP vs KBP as clear advantage for the pawns.

Here are diagrams that demonstrate the problems

[D]K2Q4/8/8/8/8/8/5r1p/7k b - - 0 1

[D]K7/8/2B5/8/8/p7/P6p/6k1 w - - 0 1

Uri
User avatar
hgm
Posts: 27807
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Good Example of Horizon effect in Eval

Post by hgm »

OK, my 'nearly Queen' scoring was specifically if the opponent only had a Queen. If he has a Rook he can always give the Rook for the Pawn, and so the Pawn obviously cannot be worth more than a Rook. So in general the rule should be "nearly the lowest enemy piece that can cover the promotion square" (so not a wrongly colored Bishop, and not Pawns).

That this still doesn't work for your example #1 doesn't worry me, as the reason here is an independent one, similar to why

[D]4K3/Q7/8/8/8/8/7r/6qk w

is not won, despite the fact that you already have the Queen there. So it doesn't prove that the Pawns isn't worth a Queen. Just that with a Queen you are often able to draw while behind seemingly decisive material.
Last edited by hgm on Sun Feb 03, 2008 10:40 pm, edited 1 time in total.
Uri Blass
Posts: 10296
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Good Example of Horizon effect in Eval

Post by Uri Blass »

hgm wrote:OK, my 'nearly Queen' scoring was specifically if the opponent only had a Queen. If he has a Rook he can always give the Rook for the Pawn, and so the Pawn obviously cannot be worth more than a Rook. So in general the rule should be "nearly the lowest enemy piece that can cover the promotion square" (so not a wrongly colored Bishop, and not Pawns).
This solves the second diagram problem but
in my first diagram the opponent has only a queen but rook+pawn in the 7th are not better than the queen.

Uri
User avatar
hgm
Posts: 27807
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Good Example of Horizon effect in Eval

Post by hgm »

Your message and my editing of the previous one crossed. I already answered you in that edit.
User avatar
Ross Boyd
Posts: 114
Joined: Wed Mar 08, 2006 9:52 pm
Location: Wollongong, Australia

Re: Good Example of Horizon effect in Eval

Post by Ross Boyd »

hgm wrote:
Ross Boyd wrote:T2 understands that Uri's example is drawn - however, she avoids capturing the h pawn so that her KPKQ evaluation doesn't kick in and return a draw. In the original position she scores Kf5 as +6.75 @ 26 ply depth.
I don't get this. After Kf5 black starts running with the Pawn, and the white King can only just step back into its square. So how are you _not_ going to take the h-Pawn? If you don't, it will be a Queen in 8 ply, so how do you ever get +6.75 at 26 ply? Only a branch that prevents black from promoting (or captures the Queen as soon as he does) could have a positive score.

If you want to put in end-game knowledge, the knowledgy you should have is that an a, c, f or h Pawn on the 7th supported by King without the opponent's King near, can only be stopped by sacrificing a Queen. It doesn't matter much if there are other Pawns on the board. If there are, but they are blaocked, it is just as drawn. Even if they have moves, they might not have enough moves.

So you should score the P on 7th supported by King as nearly a Queen, until the contrary can be shown. But you should search on, to try showing it.
Hi HG,

Regarding the h pawn, my brain must have been seriously tired. Yes, it doesn't make sense to let the h pawn run. Clearly I have some search bugs in T2 - its using some very aggressive reductive pruning so its probably just buggy.

What I'm trying to achieve is to write some heuristic interior node recognisers which can be relied on to return an accurate score and stop searching that branch any deeper. If its done properly :D it should make T2 stronger in the endgame.

For speed I want to avoid disk based EGTBs and for cache friendliness I want to avoid EGBBs.

But its nice to have the EGTBs to proof-read the accuracy of the heuristics.

Cheers,

Ross
User avatar
hgm
Posts: 27807
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Good Example of Horizon effect in Eval

Post by hgm »

Yes, it would be nice if you had recognizers that were so accurate that you could stop search immediately. But it might be a lot easier to make recognizers that only cut the search after being in the end-game a few moves. Like KRKR = draw if you are already in there 3 moves.