|
@@ -16,9 +16,6 @@ struct chessy::Bitboard
|
|
|
{
|
|
|
U64 bits;
|
|
|
|
|
|
- const Bitboard aLine = 0x0101010101010101;
|
|
|
- const Bitboard hLine = 0x8080808080808080;
|
|
|
-
|
|
|
Bitboard (void) = default;
|
|
|
Bitboard (const Bitboard&) = default;
|
|
|
~Bitboard (void) = default;
|
|
@@ -32,20 +29,30 @@ struct chessy::Bitboard
|
|
|
inline void unsetBit (int row, int column)
|
|
|
{ unsetBit(row * 8 + column); }
|
|
|
|
|
|
+
|
|
|
+ static const U64 aColumn = 0x0101010101010101;
|
|
|
+ static const U64 hColumn = 0x8080808080808080;
|
|
|
inline void moveNorth (int dist) { bits <<= (8 * dist); }
|
|
|
inline void moveSouth (int dist) { bits >>= (8 * dist); }
|
|
|
- inline void moveEast (int dist) { bits <<= dist; }
|
|
|
- inline void moveWest (int dist) { bits >>= (8 * dist); }
|
|
|
-
|
|
|
- inline Bitboard operator & (const Bitboard& b) { return bits & b.bits; }
|
|
|
- inline Bitboard operator | (const Bitboard& b) { return bits | b.bits; }
|
|
|
- inline Bitboard operator ^ (const Bitboard& b) { return bits ^ b.bits; }
|
|
|
- inline Bitboard operator ~ (void) { return ~bits; }
|
|
|
+ inline void moveNorthOne(void) { 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 operator & (const Bitboard& b) const { return bits & b.bits; }
|
|
|
+ inline Bitboard operator | (const Bitboard& b) const { return bits | b.bits; }
|
|
|
+ inline Bitboard operator ^ (const Bitboard& b) const { return bits ^ b.bits; }
|
|
|
+ inline Bitboard operator ~ (void) const { return ~bits; }
|
|
|
};
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+static_assert(std::is_pod<chessy::Bitboard>().value, "chessy::Bitboard should be a POD structure.");
|
|
|
+static_assert(std::is_trivial<chessy::Bitboard>().value, "chessy::Bitboard should be a trivial structure.");
|
|
|
+static_assert(sizeof(chessy::Bitboard) == sizeof(uint64_t), "chessy::Bitboard should be 64 bits in size.");
|
|
|
|
|
|
|
|
|
#endif /* CHESSY_BITBOARD_H */
|