Passed Pawns (endgame)

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: Passed Pawns (endgame)

Post by lech »

Eelco de Groot wrote:
lech wrote:Why in pawns.cpp (evaluate_pawns() - function) pawns in endgames don’t get bonus for a chain ?
Example:
[d] 8/p2p4/8/PP2P1P1/8/8/3P4/8 w - - 0 1
bonuses:
Pg5 – 100 (only default "r"),
Pe5+d2 – 68,
Pa5+b5 – 68.
The order by the real strong: Pa5+b5 next Pg5, Pe5+d2
Maybe I can’t see something?
Yes, I could not figure that either. Maybe you saw that I changed it to a very small plus in Rainbow Serpent but if this term essentially is tuned to zero there must be some other term missing I think. Why should being part of a pawn chain be disadvantageous? Sometimes only the foremost pawn should run but that is more a concern for passed pawns. Passed pawns are not evaluated in pawns.cpp and connected passers are underevaluated anyway in Stockfish I think, the bonus for moving a passed pawn forward even if it means leaving a supporting pawn behind are always large enough that it should not influence this pawn chain term in pawns.cpp.

Eelco
Of course, it had to be an important reason to cut a bonus for “chain” pawns in endgames.
My suggestion applies to “candidate” pawns.

Code: Select all

 pawns.cpp, PawnInfoTable::evaluate_pawns()
if (candidate)
          value += CandidateBonus[relative_rank(Us, s)];
a change:

Code: Select all

if (candidate)
          value += CandidateBonus[relative_rank(Us, s)] * (chain  ||  !(relative_rank(Us, s) > RANK_4));
In position:
[d] 8/p7/8/8/1P6/8/P7/8 w - -
white plays now 1.a4 not 1.b5
In position:
[d] 8/p7/8/8/8/8/PP6/8 w - -
white plays 1.b4

Eelco, I don’t know the code of Rainbow Serpent. I think, it is good to support SF’s team, if it is possible and welcome.
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: Passed Pawns (endgame)

Post by zamar »

lech wrote:Why in pawns.cpp (evaluate_pawns() - function) pawns in endgames don’t get bonus for a chain ?
Example:
[d] 8/p2p4/8/PP2P1P1/8/8/3P4/8 w - - 0 1
bonuses:
Pg5 – 100 (only default "r"),
Pe5+d2 – 68,
Pa5+b5 – 68.
The order by the real strong: Pa5+b5 next Pg5, Pe5+d2
Maybe I can’t see something?
This is really interesting question. Originally there was a bonus. But when we used the automatic tuning system, bonus dropped to zero. I really don't know why...
Joona Kiiski
lech
Posts: 1136
Joined: Sun Feb 14, 2010 10:02 pm

Re: Passed Pawns (endgame)

Post by lech »

lech wrote: Of course, it had to be an important reason to cut a bonus for “chain” pawns in endgames.
My suggestion applies to “candidate” pawns.

Code: Select all

 pawns.cpp, PawnInfoTable::evaluate_pawns()
if (candidate)
          value += CandidateBonus[relative_rank(Us, s)];
a change:

Code: Select all

if (candidate)
          value += CandidateBonus[relative_rank(Us, s)] * (chain  ||  !(relative_rank(Us, s) > RANK_4));
It is a "better" version of the change. :oops: C++ doesn't make everything yet. :?

Code: Select all

if (candidate) 
        if (chain  ||  !(relative_rank(Us, s) > RANK_4))
		  value += CandidateBonus[relative_rank(Us, s)];
rjgibert
Posts: 317
Joined: Mon Jun 26, 2006 9:44 am

Re: Passed Pawns (endgame)

Post by rjgibert »

zamar wrote:
lech wrote:Why in pawns.cpp (evaluate_pawns() - function) pawns in endgames don’t get bonus for a chain ?
Example:
[d] 8/p2p4/8/PP2P1P1/8/8/3P4/8 w - - 0 1
bonuses:
Pg5 – 100 (only default "r"),
Pe5+d2 – 68,
Pa5+b5 – 68.
The order by the real strong: Pa5+b5 next Pg5, Pe5+d2
Maybe I can’t see something?
This is really interesting question. Originally there was a bonus. But when we used the automatic tuning system, bonus dropped to zero. I really don't know why...
Anyone of the above can be more favorable or less favorable depending on circumstances.

Using the following "deliberately biased" set of observations:
  • Pa5+Pb5 is inflexible and Pa7 can actually create additional stalemating motifs.
    Pg5 is inflexible.
    Pe5+Pd2 is more flexible, since Pa2 can move 1 or 2 squares.
...I could reverse the order of preference. If you know a lot about pawn endings, you would realize the significance of the above observations. With a different set of observations, I can produce any order of preference desired. Which are significant when and which are not depends on "other factors." But it's kind of amusing that the tuning attempt to award bonuses for these produced zeros. I would not have predicted that, yet it is not totally implausible.
lech
Posts: 1136
Joined: Sun Feb 14, 2010 10:02 pm

Re: Passed Pawns (endgame)

Post by lech »

By SF 171 code, the pawn c5 is a “candidate”.
[d]8/1p6/8/1pP5/8/1P6/8/8 w - -

Code: Select all

 pawns.cpp, PawnInfoTable::evaluate_pawns()
candidate =   !passed
                 && !(theirPawns & file_bb(f))
                 && (  count_1s_max_15(neighboring_files_bb(f) & (behind_bb(Us, r) | rank_bb(r)) & ourPawns)
                     - count_1s_max_15(neighboring_files_bb(f) & in_front_bb(Us, r)              & theirPawns)
                     >= 0);
Why shouldn’t be?

Code: Select all

candidate =   !passed
                 && !(theirPawns & file_bb(f))
                 && (  count_1s_max_15(neighboring_files_bb(f) & (behind_bb(Us, r) | rank_bb(r)) & ourPawns)
                     - count_1s_max_15(neighboring_files_bb(f) & theirPawns)
                     >= 0);
lech
Posts: 1136
Joined: Sun Feb 14, 2010 10:02 pm

Re: Passed Pawns (endgame)

Post by lech »

zamar wrote:
lech wrote:Why in pawns.cpp (evaluate_pawns() - function) pawns in endgames don’t get bonus for a chain ?
Example:
[d] 8/p2p4/8/PP2P1P1/8/8/3P4/8 w - - 0 1
bonuses:
Pg5 – 100 (only default "r"),
Pe5+d2 – 68,
Pa5+b5 – 68.
The order by the real strong: Pa5+b5 next Pg5, Pe5+d2
Maybe I can’t see something?
This is really interesting question. Originally there was a bonus. But when we used the automatic tuning system, bonus dropped to zero. I really don't know why...
The (auto) tuning can badly work if there are some logic bugs in the code.
See example.
[d] 8/8/pp2p2p/6p1/1P1PP1P1/1P6/8/8 w - -
Score by SF 171 (pawns.cpp; PawnInfoTable::evaluate_pawns()) for this position is White: S(-87,-124) and Black: S(-1,-45) :shock:
White:
isolated b3, b4, g4
doubled b3
candidate d4
chain d4, e4
Black:
isolated e6
chain a6, b6, g5
backward h6(/2)
The penalty for both white pawns b3, b4 is until S(-92,-118).
The score of both black pawns g5, h6 is S(-7,-17), and the score of white pawn g4 is S(-36,-35).
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Passed Pawns (endgame)

Post by mcostalba »

lech wrote: The (auto) tuning can badly work if there are some logic bugs in the code.
Please, what bugs you are referring to ? Thanks.
lech
Posts: 1136
Joined: Sun Feb 14, 2010 10:02 pm

Re: Passed Pawns (endgame)

Post by lech »

mcostalba wrote:
lech wrote: The (auto) tuning can badly work if there are some logic bugs in the code.
Please, what bugs you are referring to ? Thanks.
It is better to have two bonuses for chain (e.g. Pe4 + Pd4) than only one (e.g. Pe4 + Pd5). It stoped pawns in endgames. :lol:
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Passed Pawns (endgame)

Post by mcostalba »

lech wrote:
mcostalba wrote:
lech wrote: The (auto) tuning can badly work if there are some logic bugs in the code.
Please, what bugs you are referring to ? Thanks.
It is better to have two bonuses for chain (e.g. Pe4 + Pd4) than only one (e.g. Pe4 + Pd5). It stoped pawns in endgames. :lol:
I am very sorry, I really don't understand what are you trying to say.

Could be possible for you to post a patch (also if not exactly correct) of the modification you are thinking of ? Just to better understand.

Thanks
Marco
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Passed Pawns (endgame)

Post by mcostalba »

mcostalba wrote:
I am very sorry, I really don't understand what are you trying to say.
Perhaps I have understood. Are you suggesting the following patch ?

Code: Select all

       chain =  ourPawns
              & neighboring_files_bb(f)
-             & (rank_bb(r) | rank_bb(r - (Us == WHITE ? 1 : -1)));
+             & (rank_bb(r) | rank_bb(r + 1) | rank_bb(r - 1));