Added function to bb: getting least significant 1st bit index

This commit is contained in:
rektdie committed 2024-03-03 22:19:02 +01:00
1 parent b4bc91ffc2
commit 13c7bcc092
3 files changed
+23 -1

No files matched your search

+10
View File
@@ -43,6 +43,16 @@ int Bitboard::popCount() const {
return count;
}
// LS1B = least significat first bit
int Bitboard::getLS1BIndex() const {
if (m_board) {
// count trailing bits before LS1B
return Bitboard((m_board & -m_board) - 1).popCount();
}
return -1;
}
// Operator overloading for easier comparisons
Bitboard Bitboard::operator&(const Bitboard& other) const {
return m_board & other.m_board;