Author: Zach Wegner
Date: 07:27:47 12/02/03
Go up one level in this thread
On December 02, 2003 at 07:13:13, Maurizio Di Vitto wrote:
>Hi,
>I'm from Italy and I am still writing my chess engine in c language. I
>downloaded the source code you told me, but I would like to know something more.
>I know for pieces like rook,queen and bishop we should look at the rank(or
>file)_attack[64][256] array,the first index refers to the square the piece sits
>on and the second refers to the state of the rank, so I want to know how to
>initalize this array of [64][256]. I know what state of rank means, It can be
>represented by a number like 00101001, I know about the rotated bitboard, so I
>will be pleased if I could receive some explanation about that.
>Thanks a lot.
>Maurizio Di Vitto
have two counters, x and y. do a nested loop that goes through all 64*256
possibilities. have a bitboard that is initialized to the value of y(this
variable is 0-255) shifted left by 8*RANK(x). have another bitboard, initialized
to 0, where bits are ORed in from the mask of x shifted left and right, and and
then checked to make sure it doesnt hit the mask bitboard of the occupied
squares.
so this would look like:
UINT64 o, m;
int x, y;
for (x = 0; x < 64; x++)
{
for (y = 0; y < 256; y++)
{
o = y << (x & ~7);/*same as y << (8 * (x / 8))*/
rankattacks[x][y] = 0;
m = mask[x];
while (m && !(m & o))
{
m <<= 1;
rankattacks[x][y] |= m;
}
m = mask[x];
while (m && !(m & o))
{
m >>= 1;
rankattacks[x][y] |= m;
}
}
}
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.