Xray Attacks Bitboards
Home * Board Representation * Bitboards * X-ray Attacks
The term X-ray attack was apparently originated by Kenneth Harkness. On page 25 of the April 1947 Chess Review, in his series Picture Guide to Chess, he mentioned forks and then wrote [1]:
Single Sliders
The single sliding piece, a rook, bishop or queen is specified by square index, likely from a bitscan of a piece-wise bitboard serialization of a sliding piece bitboard from a standard board-definition.
Modifying Occupancy
Following routines may be used to get all kind of x-ray attacks or defenses through the blockers for one particular slider. The idea is to intersect the sliding attacks with the desired blockers, which are subset of occupied. In a second run, those blockers are removed from the occupancy, to get the x-ray attacks as the symmetric difference of both attacks.
Alternatively one may use a condition to save the second lookup - one may use disjoint line-attacks rather than piece-attacks. If so, it makes sense to exclude the outer squares from the blockers.
X-rays with one Lookup
Another idea is to consider all kind of blockers in one run, and to traverse intersections of the x-rays attacks with different target sets, to determine the blocking piece inside a loop. In the context of absolute pins, Oliver Brausch introduced to lookup x-ray attacks through any blocker in his engine OliThink [2] - similar to any occupied lookup technique to get sliding piece attacks. Instead of the pre-calculated line-attacks we can also pre-calculate attacks behind the first blocker, including a possible second blocker. The outer squares are redundant as well. Some sample on a rank:
Since absolute pins and discovered checkers are usually quite rare, it might be worth to spend some additional memory, e.g. 8 KByte for kindergarten - x-rays. Also the switch approach is great to consider all kind of x-ray stuff on a line.
Multiple Sliders
If keeping eight disjoint ray-direction attacks from fill-routines like Kogge-Stone Algorithm one may intersect them with desired blockers - and to perform another fill with that intersection:
Blockers by Targets
The other idea is to fill the potential target set, and to intersect it with the opposite ray-direction fill of the sliders and the relevant blockers:
See also
Forum Posts
- Generating “through” attacks with rotated bitboard by Vlad Stamate, CCC, August 28, 2009 » Rotated Bitboards
External Links
- X-ray (chess) from Wikipedia
- Defunkt - See Through, Jazzopen Stuttgart 1996, 3sat broadcast, YouTube Video
lineup: Joseph Bowie, Kelvyn Bell, Larry Bowen, Bahnamous Bowie, Byron Bowie, Kim Clarke, Scooter Warner, Ronny Drayton
References
- ↑ Jack O’Keefe in Chess Note 4245. X-ray attack by Edward Winter
- ↑ Re: Question about SEE (Static exchange evaluation) by Oliver Brausch, CCC, December 18, 2007