Bitboards: added PopBit()

This commit is contained in:
rektdie committed 2024-03-04 10:05:16 +01:00
1 parent 13c7bcc092
commit 20f0ea142a
4 files changed
+9 -6

No files matched your search

+1 -1
View File
@@ -25,4 +25,4 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/types.h | $(OBJ_DIR)
# Create the object directory if it doesn't exist
$(OBJ_DIR):
mkdir -p $@
mkdir $@
+6 -3
View File
@@ -30,6 +30,12 @@ void Bitboard::SetBit(int square) {
m_board |= (1ULL << square);
}
void Bitboard::PopBit(int square) {
if (Bitboard(m_board).IsSet(square)) {
m_board &= (~Bitboard::GetSquare(square)).GetBoard();
}
}
int Bitboard::popCount() const {
U64 board = m_board;
int count = 0;
@@ -76,9 +82,6 @@ Bitboard Bitboard::operator|=(const Bitboard& other) {
Bitboard Bitboard::operator^=(const Bitboard& other) {
return m_board ^= other.m_board;
}
Bitboard Bitboard::operator*=(const Bitboard& other) {
return m_board *= other.m_board;
}
Bitboard Bitboard::operator<<(int other) {
if (other > 0) {
+1 -1
View File
@@ -15,6 +15,7 @@ public:
U64 GetBoard() const;
bool IsSet(int square) const;
void SetBit(int square);
void PopBit(int square);
void PrintBoard() const;
int popCount() const;
@@ -32,7 +33,6 @@ public:
Bitboard operator&=(const Bitboard& other);
Bitboard operator|=(const Bitboard& other);
Bitboard operator^=(const Bitboard& other);
Bitboard operator*=(const Bitboard& other);
Bitboard operator<<(int other);
Bitboard operator>>(int other);
+1 -1
View File
@@ -4,7 +4,7 @@
using U64 = uint64_t;
constexpr char StartingFen[] = "8/1BR1P1P1/2Q1p3/1P2P2p/3B1K2/3k4/3p2pP/4n3 w - - 0 1";
constexpr char StartingFen[] = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR";
enum COLOR {
White,