*/
#include <algorithm>
+#include <bitset>
#include "bitboard.h"
#include "misc.h"
Bitboard BishopTable[0x1480]; // To store bishop attacks
void init_magics(Bitboard table[], Magic magics[], Direction directions[]);
-
- // popcount16() counts the non-zero bits using SWAR-Popcount algorithm
- unsigned popcount16(unsigned u) {
- u -= (u >> 1) & 0x5555U;
- u = ((u >> 2) & 0x3333U) + (u & 0x3333U);
- u = ((u >> 4) + u) & 0x0F0FU;
- return (u * 0x0101U) >> 8;
- }
}
void Bitboards::init() {
for (unsigned i = 0; i < (1 << 16); ++i)
- PopCnt16[i] = (uint8_t)popcount16(i);
+ PopCnt16[i] = std::bitset<16>(i).count();
for (Square s = SQ_A1; s <= SQ_H8; ++s)
SquareBB[s] = (1ULL << s);