Single sliding piece attacks on the otherwise empty board or their disjoint subsets on lines or rays are that simple than none sliding pieces. We simply use pre-calculated tables for each piece-type, line or ray, indexed by square-index. To initialize those tables, one may use a fill approach with single populated from-sets, if availably anyway since used elsewhere. While the proposed line-routines here are quite small and cheap, incremental update during an initialization loop has some merits.
The various ray-,line- and piece sets are foundation of further attack calculation considering blocking pieces, for instance to mask the occupancy of relevant rays. Of course the piece attacks are union-sets of the disjoint line attacks, while the line attacks are unions of the disjoint ray attacks.
Ray Attacks
northwest north northeast
noWe nort noEa
+7 +8 +9
\ | /
west -1 <- 0 -> +1 east
/ | \
-9 -8 -7
soWe sout soEa
southwest south southeast
Rays by Line
Ray-Attacks may be conducted from Line-Attacks by intersection with "positive" and "negative" squares:
Table of Contents
Single sliding piece attacks on the otherwise empty board or their disjoint subsets on lines or rays are that simple than none sliding pieces. We simply use pre-calculated tables for each piece-type, line or ray, indexed by square-index. To initialize those tables, one may use a fill approach with single populated from-sets, if availably anyway since used elsewhere. While the proposed line-routines here are quite small and cheap, incremental update during an initialization loop has some merits.
The various ray-,line- and piece sets are foundation of further attack calculation considering blocking pieces, for instance to mask the occupancy of relevant rays. Of course the piece attacks are union-sets of the disjoint line attacks, while the line attacks are unions of the disjoint ray attacks.
Ray Attacks
northwest north northeast noWe nort noEa +7 +8 +9 \ | / west -1 <- 0 -> +1 east / | \ -9 -8 -7 soWe sout soEa southwest south southeastRays by Line
Ray-Attacks may be conducted from Line-Attacks by intersection with "positive" and "negative" squares:or with shifts instead of lookups
Positive Rays
Remember Square Mapping Considerations.By Lookup
Initialization
North attacks are simple to initialize inside a loop, starting from a1, shifting left:Similar, but tad trickier for ranks and diagonals, due to the wraps. For instance the north-east direction:
By Calculation
Orthogonal positive rays are quite cheap to calculate on the fly. For diagonal rays split the lines as mentioned.Negative Rays
Remember Square Mapping Considerations.By Lookup
Initialization
South attacks are simple to initialize inside a loop, starting from h8, shifting right:Similar, but tad trickier for ranks and diagonals, due to the wraps.
By Calculation
Orthogonal negative rays are quite cheap to calculate on the fly. For diagonal rays split the lines as mentioned.Line Attacks
By Lookup
By Calculation
To calculate them on the fly, including...... or excluding the square bit:
Piece Attacks
By Lookup
Queen . . . 1 . . . 1 1 . . 1 . . 1 . . 1 . 1 . 1 . . Rook . . 1 1 1 . . . Bishop . . . 1 . . . . 1 1 1 Q 1 1 1 1 . . . . . . . 1 . . . 1 . . . . . . 1 1 1 . . . 1 . . . . . 1 . . . . 1 . . . . . 1 . 1 . 1 . . . 1 . . . 1 . . . . . 1 . . . . 1 . . 1 . . 1 . . . 1 . 1 . . . 1 1 1 R 1 1 1 1 . . . B . . . . . . . 1 . . . . . . 1 . 1 . . . . . . 1 . . . . . 1 . . . 1 . . . . . 1 . . . . 1 . . . . . 1 .By Calculation
See also
What links here?
Up one Level