diff --git a/Makefile b/Makefile index 883e5c7..ba88710 100644 --- a/Makefile +++ b/Makefile @@ -17,10 +17,10 @@ OBJS := $(addprefix $(OBJ_DIR)/, $(notdir $(SRCS:.cpp=.o))) # Target executable Eleanor$(EXE_EXT): $(OBJS) - g++ -o $@ $^ + g++ -o $@ $^ -O3 # Rule to compile source files to object files $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/types.h | $(OBJ_DIR) - g++ -c -o $@ $< + g++ -c -o $@ $< -O3 # Create the object directory if it doesn't exist $(OBJ_DIR): diff --git a/source/bitboards.cpp b/source/bitboards.cpp index 58f3314..c61d55a 100644 --- a/source/bitboards.cpp +++ b/source/bitboards.cpp @@ -28,15 +28,15 @@ U64 Bitboard::GetBoard() const { } bool Bitboard::IsSet(int square) const { - return (1ULL << square) & m_board; + return GetSquare(square).GetBoard() & m_board; } void Bitboard::SetBit(int square) { - m_board |= (1ULL << square); + m_board |= GetSquare(square).GetBoard(); } void Bitboard::PopBit(int square) { - m_board &= ~(1ULL << square); + m_board &= ~GetSquare(square).GetBoard(); } int Bitboard::PopCount() const { diff --git a/source/bitboards.h b/source/bitboards.h index d767a28..1e64ae5 100644 --- a/source/bitboards.h +++ b/source/bitboards.h @@ -22,6 +22,10 @@ public: int getLS1BIndex() const; static Bitboard getOccupancy(int index, Bitboard attackMask); + static Bitboard GetSquare(int square) { + return (1ULL << square); + }; + Bitboard operator&(const Bitboard& other) const; Bitboard operator|(const Bitboard& other) const; Bitboard operator^(const Bitboard& other) const; diff --git a/source/movegen.cpp b/source/movegen.cpp index 1c2459c..ff2cb8b 100644 --- a/source/movegen.cpp +++ b/source/movegen.cpp @@ -18,7 +18,7 @@ static Bitboard notHGfile = notHfile & ~files[G]; Bitboard maskPawnAttacks(int side, int square) { Bitboard attacks; - Bitboard attacker = (1ULL << square); + Bitboard attacker = Bitboard::GetSquare(square); // White if (!side) { @@ -35,7 +35,7 @@ Bitboard maskPawnAttacks(int side, int square) { Bitboard maskKnightAttacks(int square) { Bitboard attacks; - Bitboard attacker = (1ULL << square); + Bitboard attacker = Bitboard::GetSquare(square); if (((attacker << noEa + north) & notAfile).GetBoard()) attacks |= (attacker << noEa + north); if (((attacker << noWe + north) & notHfile).GetBoard()) attacks |= (attacker << noWe + north); @@ -52,7 +52,7 @@ Bitboard maskKnightAttacks(int square) { Bitboard maskKingAttacks(int square) { Bitboard attacks; - Bitboard attacker = (1ULL << square); + Bitboard attacker = Bitboard::GetSquare(square); attacks |= (attacker << north); attacks |= (attacker << south);