Changes

Jump to: navigation, search

Subtracting a Rook from a Blocking Piece

288 bytes added, 21:33, 22 October 2019
no edit summary
'''[[Main Page|Home]] * [[Board Representation]] * [[Bitboards]] * [[Sliding Piece Attacks]] * Subtracting a Rook from a Blocking Piece'''
[[FILE:BishopKnightRook.jpg|border|right|thumb|link=http://chgs.elevator.umn.edu/asset/viewAsset/57f3b6787d58ae5f74bf8ba9#57f3b6d77d58ae5574bf8bb6|[[Arts#:Category:Samuel Bak|Samuel Bak]] - Bishop, Knight, Rook <ref>[http://chgs.elevator.umn.edu/asset/viewAsset/57f3b6787d58ae5f74bf8ba9#57f3b6d77d58ae5574bf8bb6 Chess in the Art of Samuel Bak], [http://www.chgs.umn.edu/ Center for Holocaust & Genocide Studies], [https://en.wikipedia.org/wiki/University_of_Minnesota [University of Minnesota]]</ref> ]]
If we think about an [[General Setwise Operations#ArithmeticalOperations|arithmetical operation]] to calculate rank-attacks of a [[Rook|rook]] or [[Queen|queen]] with bitboards, [[General Setwise Operations#Subtraction|subtraction]] comes in mind. The idea is to treat the arithmetical carry, or inverse, borrow propagation as a way to generate rook attacks in one ray direction. As long there are zeros left (empty squares) between blocker and subtracting rook, the borrow walks through, similar as a [[Sliding Pieces|sliding piece]] moves along the empty squares.
<span id="oxoro2r"></span>
=o^(o-2r)=
This trick is known as '''o^(o-2r)'''. Assuming rook '''r''' is member of the [[Occupancy|occupancy]] '''o''' may include , the rook single subtract would only clear that '''r''' or -bit, therefor subtracting '''2r''' is required to borrow from the closest blocker bit in '''o'''. However, even if '''o''' may notinclude the rook bit, the subtraction or of '''2r ''' does not affect this that bit, and - no matter whether it '''r''' is set in '''o''' or not, the [[General Setwise Operations#ExclusiveOr|xor operation]] only yields results in the changed bits as sliding rook attacks. Unfortunately it , due to borrow is propagated in direction of arithmetical more significant bits, the trick only works on [[On an empty Board#PositiveRays|positive rays]], but can be applied for [[Files|files]] or [[Diagonals|diagonals]] with leading and trailing [[General Setwise Operations#Intersection|intersections]] with the [[On an empty Board#LineAttacks|line-masks]]. For instance, north attacks of a rook on d2:
<pre>
occupancy & filemask[d] = potential blockers

Navigation menu