I have got the concept of knight moves in bitboard. I need an array knight[64] in which all possible knight moves will be stored.
But how can I get the position of my knights in bitboard without looping through the bits of knight ??
i.e. How can I know , where my knights are placed in chessboard right now ?? And how many bitboards, I need for my chess engine ?
If someone is from C# , suggest me a good datatype for storing bitboards.
General query about bitboard
- Matthias Gemuh
- Posts: 295
- Joined: Wed Jun 09, 2010 2:48 pm
- Contact:
Re: General query about bitboard
If you want to avoid scanning for bits, use piece lists (updating their locations as the pieces move around).jashwant wrote: But how can I get the position of my knights in bitboard without looping through the bits of knight ??
Aided by engines, GMs can be very strong.
http://www.hylogic.de
http://www.hylogic.de
Re: General query about bitboard
Can you explain piece list algo a little bit ? I am not getting any idea about this .If you want to avoid scanning for bits, use piece lists (updating their locations as the pieces move around).
Re: General query about bitboard
You need a bitscan function.I have got the concept of knight moves in bitboard. I need an array knight[64] in which all possible knight moves will be stored.
But how can I get the position of my knights in bitboard without looping through the bits of knight ??
i.e. How can I know , where my knights are placed in chessboard right now ?? And how many bitboards, I need for my chess engine ?
http://chessprogramming.wikispaces.com/BitScan
Its speed is critical for good performance, but you can start with something simple and optimize later. Ultimately it can be a single machine instruction.
Code: Select all
typedef struct Position {
Bitboard pawns, knights, bishops, rooks, queens; // required
Bitboard occupied; // union of above + king-square bits; used by slider attack generator
...
signed char contentOfSquare[64]; // a useful complement to the Bitboards
...
}
Bitboard tempBits = thePosition.knights;
while ( tempBits ) {
int sq = GetLowestBit( tempBits ); // bitscan
...there is a knight on sq...
ClearLowestBit( &tempBits );
}