backward pawn

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
User avatar
xr_a_y
Posts: 787
Joined: Sat Nov 25, 2017 1:28 pm
Location: France

backward pawn

Post by xr_a_y » Sat Jul 06, 2019 10:13 am

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: 3830
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany
Full name: Sven Schüle
Contact:

Re: backward pawn

Post by Sven » Sat Jul 06, 2019 4:45 pm

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: 2128
Joined: Wed Mar 08, 2006 7:47 pm
Location: Hattingen, Germany

Re: backward pawn

Post by Gerd Isenberg » Sat Jul 06, 2019 8:26 pm

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 8:35 pm, edited 2 times in total.

User avatar
xr_a_y
Posts: 787
Joined: Sat Nov 25, 2017 1:28 pm
Location: France

Re: backward pawn

Post by xr_a_y » Sat Jul 06, 2019 8:35 pm

Gerd Isenberg wrote:
Sat Jul 06, 2019 8: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: 4394
Joined: Thu Mar 09, 2006 8:40 am
Full name: Vincent Lejeune

Re: backward pawn

Post by Vinvin » Sat Jul 06, 2019 11:43 pm

It's matter of choice : an isolated pawn can be considered as backward ... or not.

Gerd Isenberg
Posts: 2128
Joined: Wed Mar 08, 2006 7:47 pm
Location: Hattingen, Germany

Re: backward pawn

Post by Gerd Isenberg » Sun Jul 07, 2019 7:16 am

xr_a_y wrote:
Sat Jul 06, 2019 8:35 pm
Gerd Isenberg wrote:
Sat Jul 06, 2019 8: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.

Post Reply