25,161
edits
Changes
no edit summary
'''Obstruction Difference''',<br/>
a subtraction approach to determine sliding piece attacks with bitboards, proposed by [[Michael Hoffmann]] <ref>[http://www.talkchess.com/forum/viewtopic.php?t=29087 DIRECT BITBOARD MOVEGENERATION] by [[Michael Hoffmann]], [[CCC]], July 23, 2009</ref>. The idea is to get disjoint [[On an empty Board#PositiveRays|positive]] and [[On an empty Board#NegativeRays|negative ray masks]] of the [[Occupancy|occupancy]], and to subtract the [[General Setwise Operations#TheMostSignificantOneBitMS1B|most significant one bit]] of the negative ray from the doubled [[General Setwise Operations#TheLeastSignificantOneBitLS1B|least siginificat significant one bit]] (LS1B) of the positive ray. The difference is finally intersected with the linemask, excluding the [[Sliding Pieces|sliding piece]] itself from the attack set. However, in 2022, [[Daniel Infuehr]] found a faster solution to calculate the obstruction difference: subtract the most significant one bit of the negative ray from the the positive ray obstruction, followed by the [[General Setwise Operations#ExclusiveOr|symmetric difference]] to flip all positive ray obstruction bits for the proper result <ref>[https://www.talkchess.com/forum3/viewtopic.php?f=7&t=79701&start=2 Re: Sliding Piece Algorithm by Abstract Syntax Tree Sifting <nowiki>[RELEASE]</nowiki>] by [[Daniel Infuehr]], [[CCC]], April 17, 2022</ref>.
=Empty Sets=
<pre>
/*
* @author Michael Hoffmann, Gerd IsenbergDaniel Infuehr
* @param U64 occ occupancy of the board
* @param SMasks* a mask structure by square and line
*/
U64 lineAttacks(U64 occ, const SMasks *pMask) {
U64 lower, upper, mMS1B, ls1bms1B, odiff;
lower = pMask->lower & occ;
upper = pMask->upper & occ;
return pMask->lineEx & odiff; // (pMask->lower | pMask->upper) & odiff;
}
}
</pre>
=Java=
<pre>
/*
* @author Michael Hoffmann, Gerd IsenbergDaniel Infuehr
* @param long occ occupancy of the board
* @param int sq 0..63
long lower = longMasks[sq][line][0] & occ;
long upper = longMasks[sq][line][1] & occ;
long mMs1b = 0x8000000000000000 >>> Long.numberOfLeadingZeros (lower | 1); long ls1b odiff = upper & ^ (upper -upper; long odiff = 2*ls1b + mMs1b);
return longMasks[sq][line][2] & odiff;
}
</pre>
=See also=
* [[SBAMG]]
=Forum Posts=
* [http://www.talkchess.com/forum/viewtopic.php?t=29087 DIRECT BITBOARD MOVEGENERATION] by [[Michael Hoffmann]], [[CCC]], July 23, 2009
* [https://www.talkchess.com/forum3/viewtopic.php?f=7&t=79701&start=2 Re: Sliding Piece Algorithm by Abstract Syntax Tree Sifting <nowiki>[RELEASE]</nowiki>] by [[Daniel Infuehr]], [[CCC]], April 17, 2022
* [https://www.talkchess.com/forum3/viewtopic.php?f=7&t=79078&start=56 Re: Comparison of all known Sliding lookup algorithms <nowiki>[CUDA]</nowiki>] by [[Daniel Infuehr]], [[CCC]], April 24, 2022
=References=
<references />
'''[[Sliding Piece Attacks|Up one Level]]'''
[[Category:Man Ray]]