Programming Topics (Computer Chess) and technical aspects as test techniques, book building, program tuning etc
Moderator: Andres Valverde
by Anonymous » 07 Jul 2005, 00:03
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!!
-
Anonymous
-
by Dann Corbit » 07 Jul 2005, 00:49
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.
}
-
Dann Corbit
-
by Dan Honeycutt » 07 Jul 2005, 00:57
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.
-
Dan Honeycutt
-
- Posts: 167
- Joined: 28 Sep 2004, 15:49
- Location: Atlanta Georgia, USA
Return to Programming and Technical Discussions
Who is online
Users browsing this forum: No registered users and 10 guests