voyagerOne wrote:
Another unorthodox method I use is:
I have a bitboard for each piece so 16 bbs not 6 for each color. I also have a unionPawn bb.
How do handle positions with more than the initial number of pieces of one type (two queens being the most obvious example)?
I would say it's overkill. In Jazz I have 6 bitboards for all piece types and 2 for each colour (so to get all white rooks I need to do "all_white_pieces & all_rooks"). Jazz uses copy-move, so I wanted the board structure to be as compact as I can get away with.
My general program (Sjaak) uses a similar approach (but it can handle up to 16 piece types and doesn't use copy-move) except that it distinguishes "north-moving" pawns and "south-moving" pawns.
I am wondering if this is an efficient way...or I should change to 6 bbs.
Not necessarily. Certainly not if the main reason you want to do it is because that's what other people are doing.
Use whatever seems most natural to you.
At some point yes, you need to convert your bits into individual moves using bitscan and clearing the bit you scanned each iteration until you're left with an empty bitboard.
So in the case of Pawns. You just can't generate all moves at once...you will need to take each bit to calculate the moves. If you do all the moves at once...you still need to scan each bit and verify its move.
voyagerOne wrote:You just can't generate all moves at once...you will need to take each bit to calculate the moves. If you do all the moves at once...you still need to scan each bit and verify its move.
Depends on what you mean by "generate all moves at once".
You can certainly very easily generate all possible pawn move destinations at once using bitshifts and occupancy masks. If you mean "generate a list of from-to tuples", then you first need to loop over the resulting bitboard and extract all the possible pawn destinations one by one (given the destination, you know where the pawn was before).
voyagerOne wrote:So in the case of Pawns. You just can't generate all moves at once...you will need to take each bit to calculate the moves. If you do all the moves at once...you still need to scan each bit and verify its move.
Am I correct with this statement?
Thanks.
Not clear. Suppose all pawns are on the original squares for white, a2-h2. I shift the whole mess left 8 bits so that now all pawns are on a3-h3. I find the first one bit which is a3, or bit 16 (a1=0, a2=8) So to=16, from=16-8, and I clear that bit. I find the first one. Which is now b3 or bit 16. To=17, from =17-8, and I clear that bit. Etc...