Only intersection with the opponent pieces is required.
We may include a possible en-passant target square.
Pawns set-wise
Working in the bitboard centric world to determine attacks and properties set-wise.
Attacks
Generate all squares that are attacked by pawns of a color. It makes sense to keep disjoint sets for both attacking directions. For move-gen disjoint east-west attacks has the advantage of unique source-target relation ship (+-7,9). After obtaining the direction-wise target-set a reverse shift is sufficient to get the source-set without further intersections and wrap issues.
One idea to combine pawn-attacks is about safe squares or push-targets for white respectively black pawns. A kind if of set-wise static exchange evaluation - only considering pawn-attacks from both sides. A square is assumed safe, if the number of own pawn defends if greater or equal than opponent pawn attacks. That is true if the own side defends a square twice, or the opposite side has no attacks at all, or own side attacks once and opponent not twice.
As usual, capture targets are the intersection of attack-sets with opponent pieces. Except en-passant captures of course. A reverse shift of disjoint direction-wise sets obtains the pawns which may capture.
To find the pawn set, which can actually capture, on the fly, we can start with the target squares as well:
Table of Contents
Of a Single Pawn
Attacks
To get attacks, we use a lookup of pre-calculated pawn-atacks, similar to knight- and king-attacks, except the need to consider color of the pawn.Captures
Only intersection with the opponent pieces is required.We may include a possible en-passant target square.
Pawns set-wise
Working in the bitboard centric world to determine attacks and properties set-wise.Attacks
Generate all squares that are attacked by pawns of a color. It makes sense to keep disjoint sets for both attacking directions. For move-gen disjoint east-west attacks has the advantage of unique source-target relation ship (+-7,9). After obtaining the direction-wise target-set a reverse shift is sufficient to get the source-set without further intersections and wrap issues.The code snippets rely on shifting bitboards, specially by one step only.
A bit-wise boolean instruction to combine those disjoint sets:
and similar for black.
Attack Maps
One idea to combine pawn-attacks is about safe squares or push-targets for white respectively black pawns. A kind if of set-wise static exchange evaluation - only considering pawn-attacks from both sides. A square is assumed safe, if the number of own pawn defends if greater or equal than opponent pawn attacks. That is true if the own side defends a square twice, or the opposite side has no attacks at all, or own side attacks once and opponent not twice.Those attack maps are among other things useful to decide about candidates and backward pawns .
Captures
As usual, capture targets are the intersection of attack-sets with opponent pieces. Except en-passant captures of course. A reverse shift of disjoint direction-wise sets obtains the pawns which may capture.To find the pawn set, which can actually capture, on the fly, we can start with the target squares as well:
What links here?
Up one Level