Passed Pawns (Bitboards)

From Chessprogramming wiki
Revision as of 16:36, 26 February 2019 by GerdIsenberg (talk | contribs)
Jump to: navigation, search

Home * Board Representation * Bitboards * Pawn Pattern and Properties * Passed Pawns

Carina Jørgensen, Pawn's Dream [1]

A Passed Pawn, also called Passer, has no opponent pawns in front on the same or adjacent files. In Bitboards, passers may be determined square- or set-wise.

Single Passer

Working in the square centric world of the board, thus using a square index of one particular pawn, likely from bitboard traversal, to lookup pre-calculated pattern.

For a single pawn we need to access a lookup-table to get all squares on the same file and adjacent file in front of the pawn. This is what we call front-span and attack spans. If the intersection of those span-union with the set of opponent pawns is empty, it is a passed pawn.

U64 arrFrontSpans[2][64];

if ( (arrFrontSpans[white][sqOfWhitePawn] & pawnBB[black]) == 0 ) -> pawn is a passer
arrFrontSpans[white][d4]
. . 1 1 1 . . .
. . 1 1 1 . . .
. . 1 1 1 . . .
. . 1 1 1 . . .
. . . p . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .

Pawns ready to promote don't need above condition, the appearance on the 7th (or 2nd) rank is already sufficient to be a passer:

if ( sqOfWhitePawn >= a7 ) -> white pawn may promote
if ( sqOfBlackPawn <= h2 ) -> black pawn may promote

Passers set-wise

Working in the bitboard centric world to determine pawn related pattern set-wise.

Passers are the pawns outside the union of all opponent frontspans and attack-frontspans.

U64 wPassedPawns(U64 wpawns, U64 bpawns) {
   U64 allFrontSpans = bFrontSpans(bpawns);
   allFrontSpans |= eastOne(allFrontSpans)
                 |  westOne(allFrontSpans);
   return wpawns & ~allFrontSpans;
}

U64 bPassedPawns(U64 bpawns, U64 wpawns) {
   U64 allFrontSpans = wFrontSpans(wpawns);
   allFrontSpans |= eastOne(allFrontSpans)
                 |  westOne(allFrontSpans);
   return bpawns & ~allFrontSpans;
}

See also

External Links

References

Up one Level