An unstoppable passed pawn

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

lech
Posts: 1136
Joined: Sun Feb 14, 2010 10:02 pm

Re: An unstoppable passed pawn

Post by lech »

rjgibert wrote:
lech wrote:Last question regarding pawn endgames.
I can’t find separate evaluation for pawn endgames (KP../KP..). Stockfish use the same common function. In many cases it can give a very bad effect.
E.g.
Thanks to bonuses and penalties from code:

Code: Select all

 evaluate.cpp; evaluate_passed_pawns_of_color()
ebonus -= Value(square_distance(ourKingSq, blockSq) * 3 * tr);
            ebonus -= Value(square_distance(ourKingSq, blockSq + pawn_push(Us)) * 1 * tr);
            ebonus += Value(square_distance(theirKingSq, blockSq) * 6 * tr);
…………..
// Are any of the squares in the pawn's path attacked or occupied by the enemy?
                if (b3 == EmptyBoardBB)
                    // No enemy attacks or pieces, huge bonus!
                    // Even bigger if we protect the pawn's path
                    ebonus += Value(tr * (b2 == b4 ? 17 : 15));
[d] 8/3k2p1/8/PK6/7p/7P/8/8 w - -
Stockfish’s score is ca. +2.5 for this lost position. The winning Pawn g7 has penalty too.
I don’t understand, how can Stockfish play any endgame, if can’t score possible pawn endgames correctly? Is there a protection I can’t see?
This position is a draw. Consider
[D] 8/8/8/8/7p/5kpP/8/6K1 w - -
with White or Black to move.
Now, I understood you.
position's score is +2.5
infinite analysis is -2.5 (depth 40 - maybe deeper)
in fact it is 0.00
Thank you and sorry for Stockfish and me too! :oops: :lol:
lech
Posts: 1136
Joined: Sun Feb 14, 2010 10:02 pm

Re: An unstoppable passed pawn

Post by lech »

In the version 1.8, SF sees this position correctly :D :
[d]8/8/6p1/2bN3p/1pPkb3/1P2p1P1/4B2P/3K4 b - -
1 ... Bf8 2. Sf6 (not 2.Ke1 ??
I think that it would be good to do a split. It can help in decision-making: to go (exchange, long exchange > 2 ply) into pawn endgames and to check „unstoppable passed pawns”, additionally.

Code: Select all

 search.cpp, extension()   
 if (   captureOrPromotion
        && pos.type_of_piece_on(move_to(m)) != PAWN
        && (  pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK)
            - pos.midgame_value_of_piece_on(move_to(m)) == Value(0))
        && !move_is_promotion(m)
        && !move_is_ep(m))
my proposition is to do it twice:

Code: Select all

if (   captureOrPromotion
        && (pos.type_of_piece_on(move_to(m)) > PAWN)
        && ( pos.non_pawn_material(pos.side_to_move()==WHITE ? BLACK : WHITE)
            - pos.midgame_value_of_piece_on(move_to(m)) == Value(0))
        && !move_is_promotion(m))
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: An unstoppable passed pawn

Post by mcostalba »

lech wrote:
my proposition is to do it twice:

Code: Select all

if (   captureOrPromotion
        && (pos.type_of_piece_on(move_to(m)) > PAWN)
        && ( pos.non_pawn_material(pos.side_to_move()==WHITE ? BLACK : WHITE)
            - pos.midgame_value_of_piece_on(move_to(m)) == Value(0))
        && !move_is_promotion(m))
This is something to test at moderate TC, say 1 minute per game (extensions tests cannot be done at super fast TC). Care to test ?

BTW you can rewrite as:

Code: Select all

    if (   captureOrPromotion
        && pos.type_of_piece_on(move_to(m)) > PAWN
        && (  pos.non_pawn_material(opposite_color(pos.side_to_move()))
            - pos.midgame_value_of_piece_on(move_to(m)) == Value(0))
        && !move_is_promotion(m))
lech
Posts: 1136
Joined: Sun Feb 14, 2010 10:02 pm

Re: An unstoppable passed pawn

Post by lech »

mcostalba wrote: Care to test ?

Code: Select all

    if (   captureOrPromotion
        && pos.type_of_piece_on(move_to(m)) > PAWN
        && (  pos.non_pawn_material(opposite_color(pos.side_to_move()))
            - pos.midgame_value_of_piece_on(move_to(m)) == Value(0))
        && !move_is_promotion(m))
I guess that a possible problem can be "tree explosion".
If no (you probably know), why to test it?
It is not a tunning or "speculation". It has a sense or not. :?
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: An unstoppable passed pawn

Post by mcostalba »

lech wrote:
mcostalba wrote: Care to test ?

Code: Select all

    if (   captureOrPromotion
        && pos.type_of_piece_on(move_to(m)) > PAWN
        && (  pos.non_pawn_material(opposite_color(pos.side_to_move()))
            - pos.midgame_value_of_piece_on(move_to(m)) == Value(0))
        && !move_is_promotion(m))
I guess that a possible problem can be "tree explosion".
If no (you probably know), why to test it?
It is not a tunning or "speculation". It has a sense or not. :?
It has a sense if it works, has no sense if it doesn't :-)


It is like this that it works, sorry.
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: An unstoppable passed pawn

Post by Don »

zamar wrote:
lech wrote:Last question regarding pawn endgames.
I can’t find separate evaluation for pawn endgames (KP../KP..). Stockfish use the same common function. In many cases it can give a very bad effect.
The Stockfish's great strength in endgame has always been a mystery for me. It doesn't use tablebases, it has very little hard-coded endgame knowledge. I think we could improve a lot by adding carefully designed endgame knowledge, but it's not an easy task.

I think the primary issue is how much damage is done when a more specialize rule is wrong. Programs generally tend to do the right thing ANYWAY if your general purpose evaluation function is done in a relatively balanced way like stockfish. Very often not knowing the position is a win is not so bad as long as it knows the position is very good - or as long it is likely to play correctly anyway.

Of course it's always better if it knows - but not if that knowledge is wrong too often.

I would rather have a first class general purpose evaluation function that a complex one with lots of rules and tricks and gimmicks.

You can usually spot those kinds of programs - they can play fantastic in some positions and horrible in others. But I think the playing ability of a chess program is all about the bad moves, not the good ones.
Uri Blass
Posts: 10312
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: An unstoppable passed pawn

Post by Uri Blass »

Don wrote:
zamar wrote:
lech wrote:Last question regarding pawn endgames.
I can’t find separate evaluation for pawn endgames (KP../KP..). Stockfish use the same common function. In many cases it can give a very bad effect.
The Stockfish's great strength in endgame has always been a mystery for me. It doesn't use tablebases, it has very little hard-coded endgame knowledge. I think we could improve a lot by adding carefully designed endgame knowledge, but it's not an easy task.

I think the primary issue is how much damage is done when a more specialize rule is wrong. Programs generally tend to do the right thing ANYWAY if your general purpose evaluation function is done in a relatively balanced way like stockfish. Very often not knowing the position is a win is not so bad as long as it knows the position is very good - or as long it is likely to play correctly anyway.

Of course it's always better if it knows - but not if that knowledge is wrong too often.

I would rather have a first class general purpose evaluation function that a complex one with lots of rules and tricks and gimmicks.

You can usually spot those kinds of programs - they can play fantastic in some positions and horrible in others. But I think the playing ability of a chess program is all about the bad moves, not the good ones.
I am not sure if stockfish is so strong in endgame and maybe the problem is the opposite and other programs are simply weak in endgames.

There are many things that stockfish does not know about endgames

For example the fact that Rook and a pawn and c pawn is often a draw.

[D]r1k5/8/8/8/P1P5/R7/1K6/8 w - - 0 1

This position is drawn by tablebases but stockfish1.8 even does not reduce the score to suspect that it is a draw relative to a different case when the pawn is at d4 and not at c4.

I guess that simple rule of reducing scores that are less than +4 in KRPP vs KR endgame(a+c pawns) when you reduce the score more when the positional evaluation is worse may help stockfish.

Uri