+ return Square(result + MS1BTable[b32]);
+}
+
+#endif // !defined(USE_BSFQ)
+
+
+/// Bitboards::print() prints a bitboard in an easily readable format to the
+/// standard output. This is sometimes useful for debugging.
+
+void Bitboards::print(Bitboard b) {
+
+ for (Rank rank = RANK_8; rank >= RANK_1; rank--)
+ {
+ std::cout << "+---+---+---+---+---+---+---+---+" << '\n';
+
+ for (File file = FILE_A; file <= FILE_H; file++)
+ std::cout << "| " << ((b & make_square(file, rank)) ? "X " : " ");
+
+ std::cout << "|\n";
+ }
+ std::cout << "+---+---+---+---+---+---+---+---+" << std::endl;
+}
+
+
+/// Bitboards::init() initializes various bitboard arrays. It is called during
+/// program initialization.
+
+void Bitboards::init() {
+
+ for (int k = 0, i = 0; i < 8; i++)
+ while (k < (2 << i))
+ MS1BTable[k++] = i;
+
+ for (Bitboard b = 0; b < 256; b++)
+ BitCount8Bit[b] = (uint8_t)popcount<Max15>(b);
+
+ for (Square s = SQ_A1; s <= SQ_H8; s++)
+ SquareBB[s] = 1ULL << s;