- typedef unsigned (Fn)(Square, Bitboard);
-
- void init_magics(Bitboard table[], Bitboard* attacks[], Bitboard magics[],
- Bitboard masks[], unsigned shifts[], Square deltas[], Fn index);
-
- // bsf_index() returns the index into BSFTable[] to look up the bitscan. Uses
- // Matt Taylor's folding for 32 bit case, extended to 64 bit by Kim Walisch.
-
- unsigned bsf_index(Bitboard b) {
- b ^= b - 1;
- return Is64Bit ? (b * DeBruijn64) >> 58
- : ((unsigned(b) ^ unsigned(b >> 32)) * DeBruijn32) >> 26;
- }
-
-
- // popcount16() counts the non-zero bits using SWAR-Popcount algorithm
-
- uint8_t popcount16(uint16_t u) {
- u -= (u >> 1) & 0x5555U;
- u = ((u >> 2) & 0x3333U) + (u & 0x3333U);
- u = ((u >> 4) + u) & 0x0F0FU;
- return (u * 0x0101U) >> 8;
- }