reimplemented the GetSquare function + enabled compiler optimization

This commit is contained in:
rektdie committed 2024-05-15 00:15:37 +02:00
1 parent 986b49b503
commit f6c2b6a881
4 files changed
+12 -8

No files matched your search

+3 -3
View File
@@ -28,15 +28,15 @@ U64 Bitboard::GetBoard() const {
}
bool Bitboard::IsSet(int square) const {
return (1ULL << square) & m_board;
return GetSquare(square).GetBoard() & m_board;
}
void Bitboard::SetBit(int square) {
m_board |= (1ULL << square);
m_board |= GetSquare(square).GetBoard();
}
void Bitboard::PopBit(int square) {
m_board &= ~(1ULL << square);
m_board &= ~GetSquare(square).GetBoard();
}
int Bitboard::PopCount() const {
+4
View File
@@ -22,6 +22,10 @@ public:
int getLS1BIndex() const;
static Bitboard getOccupancy(int index, Bitboard attackMask);
static Bitboard GetSquare(int square) {
return (1ULL << square);
};
Bitboard operator&(const Bitboard& other) const;
Bitboard operator|(const Bitboard& other) const;
Bitboard operator^(const Bitboard& other) const;
+3 -3
View File
@@ -18,7 +18,7 @@ static Bitboard notHGfile = notHfile & ~files[G];
Bitboard maskPawnAttacks(int side, int square) {
Bitboard attacks;
Bitboard attacker = (1ULL << square);
Bitboard attacker = Bitboard::GetSquare(square);
// White
if (!side) {
@@ -35,7 +35,7 @@ Bitboard maskPawnAttacks(int side, int square) {
Bitboard maskKnightAttacks(int square) {
Bitboard attacks;
Bitboard attacker = (1ULL << square);
Bitboard attacker = Bitboard::GetSquare(square);
if (((attacker << noEa + north) & notAfile).GetBoard()) attacks |= (attacker << noEa + north);
if (((attacker << noWe + north) & notHfile).GetBoard()) attacks |= (attacker << noWe + north);
@@ -52,7 +52,7 @@ Bitboard maskKnightAttacks(int square) {
Bitboard maskKingAttacks(int square) {
Bitboard attacks;
Bitboard attacker = (1ULL << square);
Bitboard attacker = Bitboard::GetSquare(square);
attacks |= (attacker << north);
attacks |= (attacker << south);