Author: Russell Reagan
Date: 21:34:27 05/25/03
I was tinkering with Crafty, and wrote a function to display bitboards so I
could see what was happening with the rotated stuff. I got the opposite of what
I expected.
white occupied...
########
########
--------
--------
--------
--------
--------
--------
black occupied...
--------
--------
--------
--------
--------
--------
########
########
I expected them to be switched, white on the bottom. The squares enum indicates
the first rank should be bits 0-7.
typedef enum { A1,B1,C1,D1,E1,F1,G1,H1,
A2,B2,C2,D2,E2,F2,G2,H2,
A3,B3,C3,D3,E3,F3,G3,H3,
A4,B4,C4,D4,E4,F4,G4,H4,
A5,B5,C5,D5,E5,F5,G5,H5,
A6,B6,C6,D6,E6,F6,G6,H6,
A7,B7,C7,D7,E7,F7,G7,H7,
A8,B8,C8,D8,E8,F8,G8,H8,
BAD_SQUARE } squares;
But it seems to be the exact opposite. The function I wrote to display the
bitboard is:
BITBOARD Mask (int i) {
return (BITBOARD)1 << i;
}
int Index (int rank, int file) {
return (rank * 8) + file;
}
void DumpBitboard (BITBOARD b) {
int rank, file;
for (rank = RANK8; rank >= RANK1; --rank) {
for (file = FILEA; file <= FILEH; ++file) {
if (b & Mask(Index(rank,file)))
putchar('#');
else
putchar('-');
}
putchar('\n');
}
}
When I printed the hex value of the bitboard for "all white pieces", I got
0xffff000000000000, indicating that rank 1 are bits 56-63, but the enum
indicates the opposite, so what am I missing?
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.