Changes

Jump to: navigation, search

On an empty Board

1,258 bytes added, 00:31, 18 January 2022
no edit summary
</pre>
===By Calculation===
To calculate them line masks for [[Ranks|ranks]], [[Files|files]], [[Diagonals|diagonals]] and [[Anti-Diagonals|antidiagonals]] on the fly, including...:
<pre>
U64 rankMask(int sq) {return C64(0xff) << (sq & 56);}
}
</pre>
The [[General Setwise Operations#GeneralizedShift|generalized shift]] version for [[Diagonals|diagonals]] and [[Anti-Diagonals|antidiagonals]] as introduced by [[Thomas Jahn]] <ref>[https://www.talkchess.com/forum3/viewtopic. or excluding php?f=7&t=79140&start=10 Re: <nowiki>[Question] </nowiki> Efficiently generate ray masks?] by [[Thomas Jahn]], [[CCC]], January 17, 2022</ref> produces shorter and faster code on modern [[x86-64]] processors due to shift instructions not affecting the flags <ref>[https://www.felixcloutier.com/x86/sarx:shlx:shrx SARX/SHLX/SHRX — Shift Without Affecting Flags]</ref>:<pre>U64 diagonalMask(int sq) { const U64( maindia = C64(0x8040201008040201); int diag = (sq&7) - (sq>>3); return diag >= 0 ? maindia >> diag*8 : maindia << -diag*8;} U64 antiDiagMask(int sq) { const U64( maindia = C64(0x0102040810204080); int diag = 7 - (sq&7) - (sq>>3); return diag >= 0 ? maindia >> diag*8 : maindia << -diag*8;}</pre>Excluding the square bit:
<pre>
U64 rankMaskEx (int sq) {return (C64(1) << sq) ^ rankMask(sq);}
=Forum Posts=
* [https://www.talkchess.com/forum3/viewtopic.php?f=7&t=79140 <nowiki>[Question]</nowiki> Efficiently generate ray masks?] by [[Daniel Infuehr]], [[CCC]], January 16, 2022
: [https://www.talkchess.com/forum3/viewtopic.php?f=7&t=79140&start=10 Re: <nowiki>[Question] </nowiki> Efficiently generate ray masks?] by [[Thomas Jahn]], [[CCC]], January 17, 2022
=References=
<references />
'''[[Sliding Piece Attacks|Up one Level]]'''

Navigation menu