33 for (
int i = 0; i < 64; i++)
42 for (
int i = 7; i >= 0; i--)
44 for (
int j = 0; j < 8; j++)
62 for(
int i = 0; i < 8 ; i++)
64 c[0] |= (member.c[i] & 0x80) >> i;
65 c[1] |= (i-1 < 0) ? (member.c[i] & 0x40) << 1-i : (member.c[i] & 0x40) >> i-1;
66 c[2] |= (i-2 < 0) ? (member.c[i] & 0x20) << 2-i : (member.c[i] & 0x20) >> i-2;
67 c[3] |= (i-3 < 0) ? (member.c[i] & 0x10) << 3-i : (member.c[i] & 0x10) >> i-3;
68 c[4] |= (i-4 < 0) ? (member.c[i] & 0x08) << 4-i : (member.c[i] & 0x08) >> i-4;
69 c[5] |= (i-5 < 0) ? (member.c[i] & 0x04) << 5-i : (member.c[i] & 0x04) >> i-5;
70 c[6] |= (i-6 < 0) ? (member.c[i] & 0x02) << 6-i : (member.c[i] & 0x02) >> i-6;
71 c[7] |= (i-7 < 0) ? (member.c[i] & 0x01) << 7-i : (member.c[i] & 0x01) >> i-7;
74 memcpy(member.c, c, 8);
83 for (
int i = 0; i < 8; i++)
85 if (member.c[7-i] & 0x80) c[i] |= 0x01;
86 if (member.c[7-i] & 0x40) c[i] |= 0x02;
87 if (member.c[7-i] & 0x20) c[i] |= 0x04;
88 if (member.c[7-i] & 0x10) c[i] |= 0x08;
89 if (member.c[7-i] & 0x08) c[i] |= 0x10;
90 if (member.c[7-i] & 0x04) c[i] |= 0x20;
91 if (member.c[7-i] & 0x02) c[i] |= 0x40;
92 if (member.c[7-i] & 0x01) c[i] |= 0x80;
95 memcpy(member.c, c, 8);
98 unsigned char Bitboard::getDiagonalRank45(
int rank,
int file,
int *newFile)
103 while (f-1 >= 0 && r-1 >= 0)
110 unsigned char toRet = 0;
112 while (f < 8 && r < 8)
124 unsigned char Bitboard::getDiagonalRank315(
int rank,
int file,
int *newFile)
129 while (f-1 >= 0 && r+1 < 8)
136 unsigned char toRet = 0;
138 while (f < 8 && r >= 0)
150 void Bitboard::setDiagonalRank45(
int rank,
int file,
unsigned char newRank)
154 while (f-1 >= 0 && r-1 >= 0)
161 while (f < 8 && r < 8)
163 if ( newRank & (0x80 >> n) )
171 void Bitboard::setDiagonalRank315(
int rank,
int file,
unsigned char newRank)
175 while (f-1 >= 0 && r+1 < 8)
182 while (f < 8 && r >= 0)
184 if ( newRank & (0x80 >> n) )
192 void Bitboard::shift(
int colOffset,
int rowOffset)
198 for (
int i = 0; i < 8; i++)
200 if ((i+rowOffset) >= 0 && (i+rowOffset) < 8)
203 c[i+rowOffset] = (colOffset < 0) ? member.c[i] << -colOffset : member.c[i] >> colOffset;
206 memcpy(member.c, c, 8);
212 b3.member.i = member.i | b2.member.i;
219 b3.member.i = member.i & b2.member.i;
226 b3.member.i = member.i xor b2.member.i;
233 b3.member.i = ~member.i;
237 Bitboard::operator bool()
239 return member.i != 0;
242 Square Bitboard::getAndClearFirstSetBit()
244 for(
int i = 0; i < 8; i++)
246 if (member.c[i] == 0)
249 if (member.c[i] & 0x80)
251 member.c[i] &= ~0x80;
254 if (member.c[i] & 0x40)
256 member.c[i] &= ~0x40;
259 if (member.c[i] & 0x20)
261 member.c[i] &= ~0x20;
264 if (member.c[i] & 0x10)
266 member.c[i] &= ~0x10;
269 if (member.c[i] & 0x8)
274 if (member.c[i] & 0x4)
279 if (member.c[i] & 0x2)
284 if (member.c[i] & 0x1)
Bitboard operator|(Bitboard b2)
bool test(int rank, int file)