Page 1 of 1

bitboards Q: 2 pieces can go to the same square

PostPosted: 07 Jul 2005, 00:03
by Anonymous
hi,

i'm rather new to chess programming. i've implemented bitboards but have a problem when 2 pieces of the same type can access the same square
for example, i have a bitboard with both white knights and they both access d4 when i generate the moves. how do i translate that into all the valid moves for the knights? do i have to generate their moves separately with 2 bitboards?

thanks!!

Re: bitboards Q: 2 pieces can go to the same square

PostPosted: 07 Jul 2005, 00:49
by Dann Corbit
It won't just be knights that cause that problem but any same color chessmen.

You have a bitmap for the knight attacks from some square and you want to find the knight moves.

If, and only if, the knight is not pinned:
{
You do an AND with ~MySideChessmen bitboard. The only place a knight cannot go on the board is a square occupied by a chessman of his same color.

Those are the knight moves.

You do an AND with OppoentSideChessmen bitboard.

Those are the attacks.
}

Re: bitboards Q: 2 pieces can go to the same square

PostPosted: 07 Jul 2005, 00:57
by Dan Honeycutt
You may have to further explain your question. The general procedure is to make a copy of your knight bitboard. You extract the first knight. By extract, I mean you locate the knight (say square c2) and you reset the bit. You add to your move list the squares where the knight can go:

c2-d4
c2-a1
etc.

Now from the copy you extract the next knight (say f3) and add his moves:

f3-d4
f3-g1
etc

When all the bits are gone from the copy of your knight bitboard, you have all the moves for the knights.

Best
Dan H.