Added function to bb: getting least significant 1st bit index
This commit is contained in:
1 parent
b4bc91ffc2
commit
13c7bcc092
3 files changed
+23
-1
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user