Nicolas Winkler 8 роки тому
батько
коміт
85478ef715
4 змінених файлів з 23 додано та 13 видалено
  1. 19 12
      src/BitBoard.h
  2. 2 0
      src/UciParser.cpp
  3. 1 0
      src/main.cpp
  4. 1 1
      src/makefile

+ 19 - 12
src/BitBoard.h

@@ -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 */

+ 2 - 0
src/UciParser.cpp

@@ -1,6 +1,8 @@
 #include "UciParser.h"
 #include <string>
 
+#include "ChessGame.h"
+
 using namespace std;
 
 int UciParser::parse(istream& in, ostream& out)

+ 1 - 0
src/main.cpp

@@ -1,4 +1,5 @@
 #include <iostream>
+#include "UciParser.h"
 
 using namespace std;
 

+ 1 - 1
src/makefile

@@ -3,7 +3,7 @@ CXX=        g++
 CXXFLAGS=   -std=c++14 -O3
 LNFLAGS=    
 DEPS=       Bitfield.h
-OBJ=        main.o UciParser.o
+OBJ=        main.o Board.o ChessGame.o UciParser.o
 
 
 %.o: %.c $(DEPS)