reimplemented the GetSquare function + enabled compiler optimization
This commit is contained in:
1 parent
986b49b503
commit
f6c2b6a881
4 files changed
+12
-8
No files matched your search
@@ -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):
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+3
-3
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user