Sliding Piece Generation in Chess Engine

Sort:
Avatar of LoganCS

Hey guys-- so I've been having some trouble wrapping my head around an issue.
I'm currently writing a bitboard based chess engine in Java (its been a ride figuring everything out). So far all of the pawn/king/knight moves work as expected and without bugs.

What I need help understanding is sliding piece move generation. I have generated the array of empty board moves for each square / piece. From my current understanding I also need to develop an array that contains each possible occupancy on each square as well-- and then somehow look up that array based on a variety of methods. 

Is this way of thinking about it correct? Is it a matter of picking every number from 0 to 2^63 and xor'ing it with the move bitboard for that square and then storing that with some method (magic/rotated bitboards) to initialize the array and accessing it the same way at run time?

Pseudocode and explanations are much appreciated. (I'm programming in Java by the way, using the >>>) 

Thank you for your time!

Avatar of eightlay

Hey there, Logan,

Hope you're well.

More efficient way is to implement it with binary operations.

You can check it on chessprogramming wiki page.

Also check Magic Bitboards methods