Difference between revisions of "Sliding Piece Attacks"

From Chessprogramming wiki
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 26: Line 26:
 
: [[Bitfoot#ABBitboards|Bitfoot - A/B Bitboards]]
 
: [[Bitfoot#ABBitboards|Bitfoot - A/B Bitboards]]
 
: [[CFish#AVX2 Attacks|CFish - AVX2 Attacks]]
 
: [[CFish#AVX2 Attacks|CFish - AVX2 Attacks]]
: [[Shifted Bitboards]]
+
* [[Exploding Bitboards]]
* [[Subtracting a Rook from a Blocking Piece]]
 
* [[Reverse Bitboards]]
 
 
* [[Hyperbola Quintessence]]
 
* [[Hyperbola Quintessence]]
 +
* [[Leorik#LeorikAttacks|Leorik Attacks]]
 
* [[Obstruction Difference]]
 
* [[Obstruction Difference]]
 +
* [[Reverse Bitboards]]
 
* [[SBAMG]]
 
* [[SBAMG]]
* [[Exploding Bitboards]]
+
* [[Shifted Bitboards]]
 +
* [[Subtracting a Rook from a Blocking Piece]]
 
<span id="AttacksbyOccupancyLookup"></span>
 
<span id="AttacksbyOccupancyLookup"></span>
 
==By Occupancy Lookup==  
 
==By Occupancy Lookup==  
Line 102: Line 103:
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=73083 Split Index Super Set Yielding (SISSY) Bitboards] by [[Michael Sherwin]], [[CCC]], February 13, 2020 » [[SISSY Bitboards]]
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=73083 Split Index Super Set Yielding (SISSY) Bitboards] by [[Michael Sherwin]], [[CCC]], February 13, 2020 » [[SISSY Bitboards]]
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=77133 I did some magic bitboard "science" and mostly learned not to worry about it] by  [[Jakob Progsch]], [[CCC]], April 20, 2021
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=77133 I did some magic bitboard "science" and mostly learned not to worry about it] by  [[Jakob Progsch]], [[CCC]], April 20, 2021
 +
* [https://www.talkchess.com/forum3/viewtopic.php?f=7&t=78693 Combining two of Bob's classic bitboard attack getters] by  [[Michael Sherwin|Mike Sherwin]], [[CCC]], November 19, 2021
 +
* [https://www.talkchess.com/forum3/viewtopic.php?f=7&t=78843 Faster than Fancy magic: Hypercube Slider lookup <nowiki>[TEASER]</nowiki>] by [[Daniel Infuehr]], [[CCC]], December 09, 2021
 +
* [https://www.talkchess.com/forum3/viewtopic.php?f=7&t=79004 Hypercube Slider Lookup - New Sliding Piece Algorithm <nowiki>[RELEASE]</nowiki>]  by [[Daniel Infuehr]], [[CCC]], December 31, 2021
 +
* [https://www.talkchess.com/forum3/viewtopic.php?f=7&t=79005 Comparison of all known Sliding lookup algorithms] by [[Daniel Infuehr]], [[CCC]], December 31, 2021
 +
* [https://www.talkchess.com/forum3/viewtopic.php?f=7&t=79078 Comparison of all known Sliding lookup algorithms <nowiki>[CUDA]</nowiki>] by [[Daniel Infuehr]], [[CCC]], January 08, 2022 » [[GPU]]
 +
* [https://www.talkchess.com/forum3/viewtopic.php?f=7&t=79332 Binary Neural Networks Sliding Piece Inference <nowiki>[Release]</nowiki>] by [[Daniel Infuehr]], [[CCC]], February 10, 2022 » [[Neural Networks]]
  
 
=External Links=
 
=External Links=

Latest revision as of 11:42, 25 March 2022

Home * Board Representation * Bitboards * Sliding Piece Attacks

Carina Jørgensen, Queen's Star [1]

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.

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.

Bitfoot - A/B Bitboards
CFish - AVX2 Attacks

By Occupancy Lookup

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

Sliding Piece Attacks in OliThink
BMI2 - PEXT Bitboards
SISSY Bitboards

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.

AVX2 Dumb7Fill

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 ...

Re: BitBoard Tests Magic v Non-Rotated 32 Bits v 64 Bits by Harald Lüßen, CCC, August 24, 2007

2010 ...

2015 ...

2020 ...

External Links

References

Up one Level