added operator overloading to Bitboard class
This commit is contained in:
1 parent
f6c2b6a881
commit
4d8a7f6a2e
5 files changed
+77
-45
No files matched your search
+30
-7
@@ -23,20 +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 GetSquare(square).GetBoard() & m_board;
|
||||
return GetSquare(square) & m_board;
|
||||
}
|
||||
|
||||
void Bitboard::SetBit(int square) {
|
||||
m_board |= GetSquare(square).GetBoard();
|
||||
m_board |= GetSquare(square);
|
||||
}
|
||||
|
||||
void Bitboard::PopBit(int square) {
|
||||
m_board &= ~GetSquare(square).GetBoard();
|
||||
m_board &= ~GetSquare(square);
|
||||
}
|
||||
|
||||
int Bitboard::PopCount() const {
|
||||
@@ -84,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;
|
||||
}
|
||||
@@ -94,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;
|
||||
@@ -114,3 +133,7 @@ Bitboard Bitboard::operator>>(int other) {
|
||||
Bitboard Bitboard::operator~() {
|
||||
return ~(m_board);
|
||||
}
|
||||
|
||||
Bitboard::operator uint64_t() {
|
||||
return m_board;
|
||||
}
|
||||
Reference in new issue
Block a user