|
@@ -1,7 +1,8 @@
|
|
|
#ifndef CHESSY_BITBOARD_H
|
|
|
-#define CHESSY_BITBOARD_H
|
|
|
+#define CHESSY_BITBOARD_H
|
|
|
|
|
|
-#include <inttypes.h>
|
|
|
+#include <cinttypes>
|
|
|
+#include <type_traits>
|
|
|
|
|
|
namespace chessy
|
|
|
{
|
|
@@ -15,9 +16,13 @@ struct chessy::Bitboard
|
|
|
{
|
|
|
U64 bits;
|
|
|
|
|
|
- Bitboard (void) = default;
|
|
|
- Bitboard (const Bitboard&) = default;
|
|
|
- ~Bitboard (void) = default;
|
|
|
+ const Bitboard aLine = 0x0101010101010101;
|
|
|
+ const Bitboard hLine = 0x8080808080808080;
|
|
|
+
|
|
|
+ Bitboard (void) = default;
|
|
|
+ Bitboard (const Bitboard&) = default;
|
|
|
+ ~Bitboard (void) = default;
|
|
|
+ inline Bitboard (U64 bits) : bits(bits) {}
|
|
|
|
|
|
inline void setBit (int i) { bits |= 1 << i; }
|
|
|
inline void unsetBit (int i) { bits |= ~(1 << i); }
|
|
@@ -27,6 +32,15 @@ struct chessy::Bitboard
|
|
|
inline void unsetBit (int row, int column)
|
|
|
{ unsetBit(row * 8 + column); }
|
|
|
|
|
|
+ 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; }
|
|
|
};
|
|
|
|
|
|
|