mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 10:06:26 +08:00
Accessor for SquareBB #2067
This is a non-functional code style change. If we add an accessor function for SquareBB we can consolidate all of the asserts. This is also a bit cleaner because all SquareBB accesses go through this method making future changes easier to manage. STC LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 63406 W: 14084 L: 14045 D: 35277 http://tests.stockfishchess.org/tests/view/5c9ea6100ebc5925cfffc9af No functional change.
This commit is contained in:
committed by
Marco Costalba
parent
7133598a98
commit
796d0ad70e
@@ -106,30 +106,16 @@ extern Magic BishopMagics[SQUARE_NB];
|
||||
/// Overloads of bitwise operators between a Bitboard and a Square for testing
|
||||
/// whether a given bit is set in a bitboard, and for setting and clearing bits.
|
||||
|
||||
inline Bitboard operator&(Bitboard b, Square s) {
|
||||
inline Bitboard square_bb(Square s) {
|
||||
assert(s >= SQ_A1 && s <= SQ_H8);
|
||||
return b & SquareBB[s];
|
||||
}
|
||||
|
||||
inline Bitboard operator|(Bitboard b, Square s) {
|
||||
assert(s >= SQ_A1 && s <= SQ_H8);
|
||||
return b | SquareBB[s];
|
||||
}
|
||||
|
||||
inline Bitboard operator^(Bitboard b, Square s) {
|
||||
assert(s >= SQ_A1 && s <= SQ_H8);
|
||||
return b ^ SquareBB[s];
|
||||
}
|
||||
|
||||
inline Bitboard& operator|=(Bitboard& b, Square s) {
|
||||
assert(s >= SQ_A1 && s <= SQ_H8);
|
||||
return b |= SquareBB[s];
|
||||
}
|
||||
|
||||
inline Bitboard& operator^=(Bitboard& b, Square s) {
|
||||
assert(s >= SQ_A1 && s <= SQ_H8);
|
||||
return b ^= SquareBB[s];
|
||||
return SquareBB[s];
|
||||
}
|
||||
|
||||
inline Bitboard operator&( Bitboard b, Square s) { return b & square_bb(s); }
|
||||
inline Bitboard operator|( Bitboard b, Square s) { return b | square_bb(s); }
|
||||
inline Bitboard operator^( Bitboard b, Square s) { return b ^ square_bb(s); }
|
||||
inline Bitboard& operator|=(Bitboard& b, Square s) { return b |= square_bb(s); }
|
||||
inline Bitboard& operator^=(Bitboard& b, Square s) { return b ^= square_bb(s); }
|
||||
|
||||
constexpr bool more_than_one(Bitboard b) {
|
||||
return b & (b - 1);
|
||||
|
||||
Reference in New Issue
Block a user