Browse Source

added makefile

Nicolas Winkler 8 years ago
parent
commit
5f4a4e4bfd
3 changed files with 42 additions and 9 deletions
  1. 19 5
      src/BitBoard.h
  2. 4 4
      src/main.cpp
  3. 19 0
      src/makefile

+ 19 - 5
src/BitBoard.h

@@ -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; }
 };
 
 

+ 4 - 4
src/main.cpp

@@ -1,9 +1,9 @@
-//#include <iostream>
-
+#include <iostream>
 
+using namespace std;
 
 auto main() -> int
 {
-    int a;
-    return a >= 3;
+    cout << "hello";
+    return 0;
 }

+ 19 - 0
src/makefile

@@ -0,0 +1,19 @@
+IDIR=       .
+CXX=        g++
+CFLAGS=     -O3 -flto
+LNFLAGS=    -flto
+DEPS=       Bitfield.h
+OBJ=        main.o UciParser.o
+
+
+%.o: %.c $(DEPS)
+	$(CXX) -c -o $@ $< $(CFLAGS)
+
+chessy: $(OBJ)
+	$(CXX) -o $@ $^ $(CFLAGS)
+
+.PHONY: clean
+
+clean:
+	rm -f *.o chessy
+