|
@@ -53,8 +53,8 @@ struct chessy::Bitboard
|
|
|
inline constexpr Bitboard(U64 bits) : bits{ bits } {}
|
|
|
inline static Bitboard fromIndex(Index i) { return U64(1) << i; }
|
|
|
|
|
|
- inline void setBit (Index i) { bits |= 1ULL << i.index; }
|
|
|
- inline void unsetBit (Index i) { bits |= ~(1ULL << i.index); }
|
|
|
+ inline void setBit (Index i) { bits |= U64(1) << i.index; }
|
|
|
+ inline void unsetBit (Index i) { bits |= ~(U64(1) << i.index); }
|
|
|
|
|
|
inline void setBit (int row, int column)
|
|
|
{ setBit(row * 8 + column); }
|
|
@@ -62,18 +62,28 @@ struct chessy::Bitboard
|
|
|
{ unsetBit(row * 8 + column); }
|
|
|
|
|
|
|
|
|
- static const U64 aColumn = 0x0101010101010101;
|
|
|
- static const U64 hColumn = 0x8080808080808080;
|
|
|
+ static const U64 aColumn = 0x0101010101010101ULL;
|
|
|
+ static const U64 hColumn = 0x8080808080808080ULL;
|
|
|
inline void moveNorth (int dist) { bits <<= (8 * dist); }
|
|
|
+ inline Bitboard north (int dist) { return bits << (8 * dist); }
|
|
|
inline void moveSouth (int dist) { bits >>= (8 * dist); }
|
|
|
+ inline Bitboard south (int dist) { return bits >> (8 * dist); }
|
|
|
inline void moveNorthOne(void) { bits <<= 8; }
|
|
|
+ inline Bitboard northOne (void) { return bits << 8; }
|
|
|
inline void moveSouthOne(void) { bits >>= 8; }
|
|
|
- inline void moveEastOne (void) { bits = (bits >> 1) & ~aColumn; }
|
|
|
- inline void moveWestOne (void) { bits = (bits << 1) & ~hColumn; }
|
|
|
- inline void moveNEOne (void) { bits = (bits << 7) & ~aColumn; }
|
|
|
- inline void moveNWOne (void) { bits = (bits << 9) & ~hColumn; }
|
|
|
- inline void moveSEOne (void) { bits = (bits >> 9) & ~aColumn; }
|
|
|
- inline void moveSWOne (void) { bits = (bits >> 7) & ~hColumn; }
|
|
|
+ inline Bitboard southOne (void) { return bits >> 8; }
|
|
|
+ inline void moveWestOne (void) { bits = (bits & ~aColumn) >> 1; }
|
|
|
+ inline Bitboard westOne (void) { return (bits & ~aColumn) >> 1; }
|
|
|
+ inline void moveEastOne (void) { bits = (bits & ~hColumn) << 1; }
|
|
|
+ inline Bitboard eastOne (void) { return (bits & ~hColumn) << 1; }
|
|
|
+ inline void moveNWOne (void) { bits = (bits << 7) & ~hColumn; }
|
|
|
+ inline Bitboard nwOne (void) { return (bits << 7) & ~hColumn; }
|
|
|
+ inline void moveNEOne (void) { bits = (bits << 9) & ~aColumn; }
|
|
|
+ inline Bitboard neOne (void) { return (bits << 9) & ~aColumn; }
|
|
|
+ inline void moveSWOne (void) { bits = (bits >> 9) & ~hColumn; }
|
|
|
+ inline Bitboard swOne (void) { return (bits >> 9) & ~hColumn; }
|
|
|
+ inline void moveSEOne (void) { bits = (bits >> 7) & ~aColumn; }
|
|
|
+ inline Bitboard seOne (void) { return (bits >> 7) & ~aColumn; }
|
|
|
|
|
|
inline void operator &= (const Bitboard& b) { bits &= b.bits; }
|
|
|
inline void operator |= (const Bitboard& b) { bits |= b.bits; }
|
|
@@ -89,10 +99,11 @@ struct chessy::Bitboard
|
|
|
inline explicit operator bool(void) const { return bits != 0; }
|
|
|
|
|
|
inline Bitboard mirror(void) const { return byteswap(bits); }
|
|
|
+ inline Index getLeastSignificantBit (void) const { return trailingZeroes(bits); }
|
|
|
};
|
|
|
|
|
|
|
|
|
-static_assert(std::is_pod<chessy::Bitboard>().value,
|
|
|
+static_assert(std::is_pod<chessy::Bitboard>::value,
|
|
|
"chessy::Bitboard should be a POD structure.");
|
|
|
static_assert(sizeof(chessy::Bitboard) == sizeof(uint64_t),
|
|
|
"chessy::Bitboard should be 64 bits in size.");
|