New RookAttacks() - possibly

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Gerd Isenberg
Posts: 2142
Joined: Wed Mar 08, 2006 7:47 pm
Location: Hattingen, Germany

Re: New RookAttacks() - possibly

Post by Gerd Isenberg » Thu Feb 13, 2020 8:51 pm

Michael Sherwin wrote:
Wed Feb 12, 2020 11:46 pm
I'm having a difficult time. :roll:

Code: Select all

u64 RookAttacks(u08 sq, bbu occ) {
  u64 bb = ss1[sq][(occ.b64 >> ((sq & 56) + 1)) & 63];
  occ.b64 >>= (sq & 7) & 0x0001010101010100;
  bb &= ss2[sq][0][occ.b08.rank1];
  bb &= ss2[sq][1][occ.b08.rank2];
  bb &= ss2[sq][2][occ.b08.rank3];
  bb &= ss2[sq][3][occ.b08.rank4];
  bb &= ss2[sq][4][occ.b08.rank5];
  bb &= ss2[sq][5][occ.b08.rank6];
  return bb;
Wow! Takes some time to understand and verify ;-)

Michael Sherwin
Posts: 3140
Joined: Fri May 26, 2006 1:00 am
Location: WY, USA
Full name: Michael Sherwin

Re: New RookAttacks() - possibly

Post by Michael Sherwin » Thu Feb 13, 2020 9:25 pm

Gerd Isenberg wrote:
Thu Feb 13, 2020 8:51 pm
Michael Sherwin wrote:
Wed Feb 12, 2020 11:46 pm
I'm having a difficult time. :roll:

Code: Select all

u64 RookAttacks(u08 sq, bbu occ) {
  u64 bb = ss1[sq][(occ.b64 >> ((sq & 56) + 1)) & 63];
  occ.b64 >>= (sq & 7) & 0x0001010101010100;
  bb &= ss2[sq][0][occ.b08.rank1];
  bb &= ss2[sq][1][occ.b08.rank2];
  bb &= ss2[sq][2][occ.b08.rank3];
  bb &= ss2[sq][3][occ.b08.rank4];
  bb &= ss2[sq][4][occ.b08.rank5];
  bb &= ss2[sq][5][occ.b08.rank6];
  return bb;
Wow! Takes some time to understand and verify ;-)
Hi Gerd, Glad to see that you are still around! :D

I started a new thread in which I believe that I did a better job explaining.
I hate if statements. Pawns demand if statements. Therefore I hate pawns.

Post Reply