added bitboard overloads + removed GetBoard()

This commit is contained in:
rektdie committed 2024-06-18 19:15:14 +02:00
1 parent a23918ab8d
commit d566c6d0e4
5 files changed
+127 -97

No files matched your search

+31 -10
View File
@@ -23,22 +23,16 @@ void Bitboard::PrintBoard() const {
std::cout << " Board: 0x" << std::hex << m_board << '\n';
}
U64 Bitboard::GetBoard() const {
return m_board;
}
bool Bitboard::IsSet(int square) const {
return (1ULL << square) & m_board;
return GetSquare(square) & m_board;
}
void Bitboard::SetBit(int square) {
m_board |= (1ULL << square);
m_board |= GetSquare(square);
}
void Bitboard::PopBit(int square) {
if (Bitboard(m_board).IsSet(square)) {
m_board &= (~Bitboard::GetSquare(square)).GetBoard();
}
m_board &= ~GetSquare(square);
}
int Bitboard::PopCount() const {
@@ -86,6 +80,19 @@ Bitboard Bitboard::operator*(const Bitboard& other) const {
return m_board * other.m_board;
}
Bitboard Bitboard::operator&(const uint64_t& other) const {
return m_board & other;
}
Bitboard Bitboard::operator|(const uint64_t& other) const {
return m_board | other;
}
Bitboard Bitboard::operator^(const uint64_t& other) const {
return m_board ^ other;
}
Bitboard Bitboard::operator*(const uint64_t& other) const {
return m_board * other;
}
Bitboard Bitboard::operator&=(const Bitboard& other) {
return m_board &= other.m_board;
}
@@ -96,6 +103,16 @@ Bitboard Bitboard::operator^=(const Bitboard& other) {
return m_board ^= other.m_board;
}
Bitboard Bitboard::operator&=(const uint64_t& other) {
return m_board &= other;
}
Bitboard Bitboard::operator|=(const uint64_t& other) {
return m_board |= other;
}
Bitboard Bitboard::operator^=(const uint64_t& other) {
return m_board ^= other;
}
Bitboard Bitboard::operator<<(int other) {
if (other > 0) {
return m_board << other;
@@ -115,4 +132,8 @@ Bitboard Bitboard::operator>>(int other) {
Bitboard Bitboard::operator~() {
return ~(m_board);
}
}
Bitboard::operator uint64_t() {
return m_board;
}