|
@@ -7,6 +7,7 @@
|
|
namespace chessy
|
|
namespace chessy
|
|
{
|
|
{
|
|
using U64 = uint64_t;
|
|
using U64 = uint64_t;
|
|
|
|
+ using Index = int8_t;
|
|
|
|
|
|
struct Bitboard;
|
|
struct Bitboard;
|
|
}
|
|
}
|
|
@@ -20,6 +21,7 @@ struct chessy::Bitboard
|
|
Bitboard (const Bitboard&) = default;
|
|
Bitboard (const Bitboard&) = default;
|
|
~Bitboard (void) = default;
|
|
~Bitboard (void) = default;
|
|
inline Bitboard (U64 bits) : bits(bits) {}
|
|
inline Bitboard (U64 bits) : bits(bits) {}
|
|
|
|
+ inline Bitboard (Index row, Index column) : bits(row + column * 8) {}
|
|
|
|
|
|
inline void setBit (int i) { bits |= 1 << i; }
|
|
inline void setBit (int i) { bits |= 1 << i; }
|
|
inline void unsetBit (int i) { bits |= ~(1 << i); }
|
|
inline void unsetBit (int i) { bits |= ~(1 << i); }
|
|
@@ -47,12 +49,18 @@ struct chessy::Bitboard
|
|
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 ^ (const Bitboard& b) const { return bits ^ b.bits; }
|
|
inline Bitboard operator ~ (void) const { return ~bits; }
|
|
inline Bitboard operator ~ (void) const { return ~bits; }
|
|
|
|
+ inline bool operator == (const Bitboard& b) const { return bits == b.bits; }
|
|
|
|
+ inline bool operator != (const Bitboard& b) const { return bits != b.bits; }
|
|
|
|
+ inline operator U64(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.");
|
|
|
|
|
|
+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 */
|
|
#endif /* CHESSY_BITBOARD_H */
|