Bitboards: added PopBit()
This commit is contained in:
1 parent
13c7bcc092
commit
20f0ea142a
4 files changed
+9
-6
No files matched your search
@@ -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
|
# Create the object directory if it doesn't exist
|
||||||
$(OBJ_DIR):
|
$(OBJ_DIR):
|
||||||
mkdir -p $@
|
mkdir $@
|
||||||
@@ -30,6 +30,12 @@ void Bitboard::SetBit(int square) {
|
|||||||
m_board |= (1ULL << 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 {
|
int Bitboard::popCount() const {
|
||||||
U64 board = m_board;
|
U64 board = m_board;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -76,9 +82,6 @@ Bitboard Bitboard::operator|=(const Bitboard& other) {
|
|||||||
Bitboard Bitboard::operator^=(const Bitboard& other) {
|
Bitboard Bitboard::operator^=(const Bitboard& other) {
|
||||||
return m_board ^= other.m_board;
|
return m_board ^= other.m_board;
|
||||||
}
|
}
|
||||||
Bitboard Bitboard::operator*=(const Bitboard& other) {
|
|
||||||
return m_board *= other.m_board;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bitboard Bitboard::operator<<(int other) {
|
Bitboard Bitboard::operator<<(int other) {
|
||||||
if (other > 0) {
|
if (other > 0) {
|
||||||
|
|||||||
+1
-1
@@ -15,6 +15,7 @@ public:
|
|||||||
U64 GetBoard() const;
|
U64 GetBoard() const;
|
||||||
bool IsSet(int square) const;
|
bool IsSet(int square) const;
|
||||||
void SetBit(int square);
|
void SetBit(int square);
|
||||||
|
void PopBit(int square);
|
||||||
void PrintBoard() const;
|
void PrintBoard() const;
|
||||||
|
|
||||||
int popCount() 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^=(const Bitboard& other);
|
Bitboard operator^=(const Bitboard& other);
|
||||||
Bitboard operator*=(const Bitboard& other);
|
|
||||||
|
|
||||||
Bitboard operator<<(int other);
|
Bitboard operator<<(int other);
|
||||||
Bitboard operator>>(int other);
|
Bitboard operator>>(int other);
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
using U64 = uint64_t;
|
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 {
|
enum COLOR {
|
||||||
White,
|
White,
|
||||||
|
|||||||
Reference in new issue
Block a user