Home * Board Representation * Bitboards * Sliding Piece Attacks
Queen's_Star.jpg

This is basically about how to calculate attack-sets of sliding pieces for evaluation and move-generation purposes. While the attack-sets of pawn, king and knight are only dependent on their origin square, sliding pieces like rook, bishop or queen have to consider occupancy, as pieces may block the attack-ray in one particular direction.
Carina Jørgensen, Queen's Star [1]

Move targets

Move target sets from attack-sets require intersection


Single Sliding Piece Attacks

The single sliding piece, a rook, bishop or queen is determined by square index, likely from a bitscan of a piece-wise bitboard serialization of a sliding piece bitboard from a standard board-definition.

On an empty Board

Sliding piece attack sets or their disjoint subsets on lines or rays on an otherwise empty board are that simple than none sliding pieces. They are often base of further attack calculations.

Tinker's Approach

Brian Richardson proposed a move generation approach as used in Tinker based on rook or bishop attacks on the otherwise empty board [2]. While serializing all potential targets, he tests for legality inside the loop body, that is whether the inbetween squares of origin and target are empty. This is not in the "real" bitboard spirit to determine attack sets in advance rather than to test individual elements of a superset belonging to a set, but at least it allows traversing disjoint target sets i.e. for captures in quiescence search.

By Calculation

Some bit-twiddling ray-wise and line-wise approaches, unfortunately not always for all directions.

By Occupancy Lookup

Covering line-attacks in one run, magic bitboards even covers rook- and bishop-attacks in one run.

Miscellaneous


Multiple Sliding Pieces

For bitsets with multiple sliding pieces one can apply a fill algorithm in each of the eight ray-directions to determine attacks. Since we keep disjoint directions, there is still a unique 1:1 relation from each bit of the target set to it's source square. This approach is great to determine target sets we may reach in two or more moves. One may use the union of rooks and queen(s), respectively bishops or queen(s) though.

If applied for move generation we better traverse directions rather than sliding pieces. Naturally this approach becomes less efficient, the less sliders are processed in parallel. Of course, one should avoid processing empty sets.

See also


Forum Posts

1999

2000 ...

2005 ...

2010 ...

2015 ...


External Links


References

  1. ^ Queen's Star 2009 by Carina Jørgensen
  2. ^ Movegen Re: Bitmap Type Re: Tinker 81 secs Re: Testing speed by Brian Richardson, CCC, April 24, 2000


Up one Level