backward pawn

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

backward pawn

Post by xr_a_y »

in this position

[d] 1k6/6p1/5p1p/5P1P/8/8/8/5K2 w - - 0 1

The bitboard algorithm from CPW is considering f5 and h5 as backward (and of course g7 also, but this is fine ...)

Code: Select all

U64 wBackward(U64 wpawns, U64 bpawns) {
   U64 stops = wpawns << 8;
   U64 wAttackSpans = wEastAttackFrontSpans(wpawns)
                    | wWestAttackFrontSpans(wpawns);
   U64 bAttacks     = bPawnEastAttacks(bpawns)
                    | bPawnWestAttacks(bpawns);
   return (stops & bAttacks & ~wAttackSpans) >> 8;
}
It feels wrong to me. Shall only stop square NOT already occupied by a pawn shall be considered ?
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: backward pawn

Post by Sven »

In my view f5 and h5 are not backward but g7 is. My reason: the statement "the backward pawn is not able to push forward without being lost" (https://www.chessprogramming.org/Backward_Pawn) is not applicable if the stop square is occupied. However, available definitions vary a lot. CPW points to some forum posts on that topic, e.g. http://www.talkchess.com/forum3/viewtopic.php?t=57861
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)
Gerd Isenberg
Posts: 2250
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: backward pawn

Post by Gerd Isenberg »

You strictly are right. The routine may exclude rams (or even stops not occupied by any pawn):

Code: Select all

U64 wBackward(U64 wpawns, U64 bpawns) {
   U64 stops = (wpawns << 8) & ~bpawns;
   U64 wAttackSpans = wEastAttackFrontSpans(wpawns)
                    | wWestAttackFrontSpans(wpawns);
   U64 bAttacks     = bPawnEastAttacks(bpawns)
                    | bPawnWestAttacks(bpawns);
   return (stops & bAttacks & ~wAttackSpans) >> 8;
}
Otoh the page states:
"What about a backward ram or faked candidates or even levers?"
Last edited by Gerd Isenberg on Sat Jul 06, 2019 10:35 pm, edited 2 times in total.
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: backward pawn

Post by xr_a_y »

Gerd Isenberg wrote: Sat Jul 06, 2019 10:26 pm You are right. The routine should exclude rams:

Code: Select all

U64 wBackward(U64 wpawns, U64 bpawns) {
   U64 stops = (wpawns << 8) & ~bpawns;
   U64 wAttackSpans = wEastAttackFrontSpans(wpawns)
                    | wWestAttackFrontSpans(wpawns);
   U64 bAttacks     = bPawnEastAttacks(bpawns)
                    | bPawnWestAttacks(bpawns);
   return (stops & bAttacks & ~wAttackSpans) >> 8;
}
Thanks for the clarification
Vinvin
Posts: 5228
Joined: Thu Mar 09, 2006 9:40 am
Full name: Vincent Lejeune

Re: backward pawn

Post by Vinvin »

It's matter of choice : an isolated pawn can be considered as backward ... or not.
Gerd Isenberg
Posts: 2250
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: backward pawn

Post by Gerd Isenberg »

xr_a_y wrote: Sat Jul 06, 2019 10:35 pm
Gerd Isenberg wrote: Sat Jul 06, 2019 10:26 pm You are right. The routine should exclude rams:

Code: Select all

U64 wBackward(U64 wpawns, U64 bpawns) {
   U64 stops = (wpawns << 8) & ~bpawns;
   U64 wAttackSpans = wEastAttackFrontSpans(wpawns)
                    | wWestAttackFrontSpans(wpawns);
   U64 bAttacks     = bPawnEastAttacks(bpawns)
                    | bPawnWestAttacks(bpawns);
   return (stops & bAttacks & ~wAttackSpans) >> 8;
}
Thanks for the clarification
After thinking a bit, I would suggest to keep the routine as it was - to determine pawns with a permanent weakened stop square (stop is not member of own front-attackspans but controlled by a sentry) - to exclude further subsets later. Not only rammed pawns, but with mutual backwardness to exclude the more advanced - here f5 and h5, even without the rams f6, h6, are mutual backward due to the real straggler on g7 (halfopen backward on rank 2,3 aka 7,6), but more advanced and therefor not considered backward in the Kmoch sense of definition: "If two opposing pawns on adjacent files in knight distance are mutually backward, the more advanced is not considered backward".

However to assign exactly what penalties for what degrees of backwardness inside a chess program is an other issue. Stragglers (halfopen on rank 2,3) are surely the worst instance of backward pawns. Other pawn sets with weak stops/telestops or frontspans may receive a small penalty if not considered elsewhere, i.e. as member of levers (qsearch), rammed or isolated pawns.