Rewrite some bitboard init code

And move the static function Position::attacks_from() to
bitboard code renaming it attacks_bb()

No functional change.
This commit is contained in:
Marco Costalba
2013-11-30 10:27:23 +01:00
parent 6ea5dc294c
commit 034a2b04f2
5 changed files with 27 additions and 36 deletions

View File

@@ -254,6 +254,16 @@ inline Bitboard attacks_bb(Square s, Bitboard occ) {
return (Pt == ROOK ? RAttacks : BAttacks)[s][magic_index<Pt>(s, occ)];
}
inline Bitboard attacks_bb(Piece p, Square s, Bitboard occ) {
switch (type_of(p))
{
case BISHOP: return attacks_bb<BISHOP>(s, occ);
case ROOK : return attacks_bb<ROOK>(s, occ);
case QUEEN : return attacks_bb<BISHOP>(s, occ) | attacks_bb<ROOK>(s, occ);
default : return StepAttacksBB[p][s];
}
}
/// lsb()/msb() finds the least/most significant bit in a nonzero bitboard.
/// pop_lsb() finds and clears the least significant bit in a nonzero bitboard.