33 #define DEBUG_BITBOARD_INITIALIZATION 0 35 #if DEBUG_BITBOARD_INITIALIZATION 53 return CW_MASK_T_CONST(1) << index();
59 return CW_MASK_T_CONST(1) << (col + (row << 3));
249 #if DEBUG_BITBOARD_INITIALIZATION 250 uint64_t
const bitboard_initialization_magic = 1212121212121212121;
251 uint64_t
const bitboard_destructed_magic = 555555555555555555;
267 #if DEBUG_BITBOARD_INITIALIZATION 269 uint64_t M_initialized;
273 #if DEBUG_BITBOARD_INITIALIZATION 275 ~
BitBoard() { M_initialized = bitboard_destructed_magic; }
277 bool is_initialized()
const {
return M_initialized == bitboard_initialization_magic; }
290 #if DEBUG_BITBOARD_INITIALIZATION 291 assert(other.is_initialized());
292 M_initialized = bitboard_initialization_magic;
300 #if DEBUG_BITBOARD_INITIALIZATION 301 M_initialized = bitboard_initialization_magic;
309 #if DEBUG_BITBOARD_INITIALIZATION 310 M_initialized = bitboard_initialization_magic;
318 #if DEBUG_BITBOARD_INITIALIZATION 319 M_initialized = bitboard_initialization_magic;
327 #if DEBUG_BITBOARD_INITIALIZATION 328 M_initialized = bitboard_initialization_magic;
341 #if DEBUG_BITBOARD_INITIALIZATION 342 assert(bitboard.is_initialized());
343 M_initialized = bitboard_initialization_magic;
352 #if DEBUG_BITBOARD_INITIALIZATION 353 M_initialized = bitboard_initialization_magic;
379 #if DEBUG_BITBOARD_INITIALIZATION 380 M_initialized = bitboard_initialization_magic;
388 #if DEBUG_BITBOARD_INITIALIZATION 389 M_initialized = bitboard_initialization_magic;
391 M_bitmask = CW_MASK_T_CONST(0xffffffffffffffff);
472 operator void*()
const {
return reinterpret_cast<void*
>(
M_bitmask); }
475 operator void*()
const {
return M_bitmask ? (
void*)1 : 0; }
BitBoardData const g6
The square g6.
BitBoardData const b8
The square b8.
BitBoardData const wdl_3
The white diagonal from c8 to h3.
BitBoardData const d8
The square d8.
BitBoardData const bdl_4
The black diagonal from b8 to h2.
bool test(BitBoard const& bitboard) const
Test if any bit in bitboard is set.
BitBoardData const b7
The square b7.
BitBoardData const a8
The square a8.
BitBoardData const c8
The square c8.
void reset(Index const& index)
Reset the bit at index.
A namespace for all chess related objects that are not related to the GUI.
BitBoard(mask_t bitmask)
Construct a BitBoard from a constant or mask (for internal use only).
mask_t M_bitmask
A one-bit-per-square chessboard mask.
void toggle(BitBoardData bitboard)
Toggle the bits from bitboard.
BitBoardData const c4
The square c4.
BitBoardData const file_h
The h-file.
BitBoardData const h7
The square h7.
BitBoardData const bdr_5
The black diagonal from c1 to h6.
This file contains the declaration of class Index.
BitBoardData const rank_2
The second rank.
BitBoardData const bdl_8
The black diagonal from a1 to a1.
BitBoardData const wdr_6
The white diagonal from d1 to h5.
BitBoardData const wdr_2
The white diagonal from a6 to c8.
BitBoardData const f1
The square f1.
BitBoardData operator~(BitBoardData x)
Calculate the inverse of the bitboard constant.
BitBoardData const a5
The square a5.
Index mask2index(mask_t mask)
Convert a single bit mask into it's Index.
BitBoardData const wdr_4
The white diagonal from a2 to g8.
mask_t index2mask(Index index)
Convert Index to a mask_t.
BitBoardData const f3
The square f3.
BitBoardData const bdr_6
The black diagonal from e1 to h4.
BitBoardData const h1
The square h1.
BitBoardData const h2
The square h2.
BitBoardData const file_a
The a-file.
void reset(BitBoardData bitboard)
Reset the bits from bitboard.
BitBoardData const d6
The square d6.
BitBoardData const bdr_7
The black diagonal from g1 ti h2.
bool test(BitBoardData bitboard) const
Test if any bit in bitboard is set.
BitBoardData const a1
The square a1.
void next_bit_in(uint64_t mask)
Advance the index to the next bit that is set in mask.
BitBoardData const a4
The square a4.
The POD base type of class BitBoard.
BitBoardData const file_b
The b-file.
BitBoardData const wdr_7
The white diagonal from f1 to h3.
BitBoardData const file_g
The g-file.
BitBoardData const bdl_7
The black diagonal from a3 to c1.
BitBoardData const a7
The square a7.
BitBoardData const h4
The square h4.
BitBoardData const wdl_1
The white diagonal from g8 to h7.
BitBoard()
Construct an uninitialized BitBoard.
BitBoardData const c3
The square c3.
bool test(mask_t mask) const
Test if any bit in mask is set.
BitBoardData const g5
The square g5.
BitBoardData const e1
The square e1.
BitBoardData const rank_7
The seventh rank.
BitBoardData const c1
The square c1.
BitBoardData const file_d
The d-file.
BitBoardData const b5
The square b5.
BitBoardData const h6
The square h6.
A one-boolean-per-square chessboard.
The index of a chess square.
bool test() const
Test if any bit is set at all.
BitBoard(BitBoardData data)
Construct a BitBoard from a constant.
BitBoardData const e8
The square e8.
BitBoardData const g2
The square g2.
BitBoardData operator|(BitBoardData x, BitBoardData y)
Calculate the union of two bit board constants.
bool test(int col, int row) const
Test if the bit at col, row is set.
BitBoardData const bdl_2
The black diagonal from f8 to h6.
BitBoardData const b3
The square b3.
BitBoardData const wdr_8
The white diagonal from h1 to h1.
BitBoardData operator&(BitBoardData x, BitBoardData y)
Calculate the intersection of two bit board constants.
BitBoardData const e6
The square e6.
BitBoardData const g7
The square g7.
BitBoardData const a3
The square a3.
BitBoardData const file_e
The e-file.
BitBoardData const a6
The square a6.
BitBoardData const d5
The square d5.
void reset(int col, int row)
Reset the bit at col, row.
uint64_t mask_t
The type of an internal BitBoard mask.
BitBoardData const d1
The square d1.
BitBoardData const e5
The square e5.
BitBoard(int col, int row)
Construct a BitBoard with a single bit set at col, row.
BitBoardData const g4
The square g4.
BitBoard(Index const& index)
Construct a BitBoard with a single bit set at index.
BitBoardData const c6
The square c6.
BitBoardData const bdr_2
The black diagonal from a5 to d8.
BitBoardData const bdl_5
The black diagonal from a7 to g1.
BitBoardData const rank_3
The third rank.
BitBoardData const b1
The square b1.
BitBoardData const g8
The square g8.
BitBoardData const b2
The square b2.
BitBoardData const c7
The square c7.
BitBoardData const rank_8
The eighth rank.
BitBoardData const e4
The square e4.
BitBoardData const b6
The square b6.
BitBoardData const b4
The square b4.
BitBoardData const f4
The square f4.
BitBoardData const wdr_3
The white diagonal from a4 to e8.
BitBoardData const bdl_6
The black diagonal from a5 to e1.
BitBoardData const e2
The square e2.
void toggle(int col, int row)
Toggle the bit at col, row.
BitBoardData const h8
The square h8.
bool test(Index const& index) const
Test if the bit at index is set.
BitBoardData const bdl_3
The black diagonal from d8 to h4.
BitBoardData const f2
The square f2.
BitBoard operator~() const
Return the inverse of the bitboard.
BitBoardData const file_f
The f-file.
void toggle(mask_t mask)
Toggle the bits from mask.
void toggle(Index const& index)
Toggle the bit at index.
void toggle(BitBoard const& bitboard)
Toggle the bits from bitboard.
BitBoard(BitBoard const& other)
Construct a BitBoard from another BitBoard.
BitBoardData const wdl_2
The white diagonal from e8 to h5.
BitBoardData const wdr_5
The white diagonal from b1 to h7.
IndexData const index_pre_begin
A constant representing& #39;one before the start'.
BitBoardData const f8
The square f8.
BitBoardData const rank_5
The fifth rank.
BitBoardData const wdr_1
The white diagonal from a8 to a8.
BitBoardData operator^(BitBoardData x, BitBoardData y)
Calculate the union minus the intersection of two bit board constants.
BitBoard & operator=(BitBoard const& bitboard)
Assignment from other BitBoard.
BitBoardData const g1
The square g1.
BitBoardData const wdl_7
The white diagonal from a2 to b1.
BitBoardData const bdr_3
The black diagonal from a3 to f8.
BitBoardData const rank_4
The fourth rank.
mask_t operator()() const
Return the underlaying bitmask.
BitBoardData const d2
The square d2.
BitBoardData const wdl_6
The white diagonal from a4 to d1.
BitBoardData const f5
The square f5.
BitBoardData const e7
The square e7.
BitBoardData const bdr_4
The black diagonal from a1 to h8.
BitBoardData const d3
The square d3.
BitBoardData const rank_6
The sixth rank.
void reset(mask_t mask)
Reset the bits from mask.
BitBoardData const d7
The square d7.
BitBoardData const wdl_4
The white diagonal from a8 to h1.
void reset(BitBoard const& bitboard)
Reset the bits from bitboard.
mask_t colrow2mask(int col, int row)
Convert a col, row pair to a mask_t.
BitBoardData const h5
The square h5.
void reset()
Set all values to FALSE.
BitBoardData const file_c
The c-file.
BitBoardData const h3
The square h3.
BitBoardData const a2
The square a2.
BitBoardData const wdl_5
The white diagonal from a6 to f1.
BitBoardData const c2
The square c2.
BitBoardData const bdr_1
The black diagonal from a7 to b8.
BitBoardData const c5
The square c5.
BitBoardData const bdl_1
The black diagonal from h8 to h8.
BitBoardData const rank_1
The first rank.
BitBoard & operator=(BitBoardData bitboard)
Assignment from a constant.
BitBoardData const g3
The square g3.
BitBoardData const e3
The square e3.
BitBoardData const d4
The square d4.
BitBoardData const f6
The square f6.
BitBoardData const f7
The square f7.