mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
parent
6d24ef8585
commit
c0cb713a00
2 changed files with 11 additions and 10 deletions
|
@ -251,6 +251,7 @@ namespace {
|
||||||
|
|
||||||
void init_magics(Bitboard table[], Magic magics[], Square deltas[]) {
|
void init_magics(Bitboard table[], Magic magics[], Square deltas[]) {
|
||||||
|
|
||||||
|
// Optimal PRNG seeds to pick the correct magics in the shortest time
|
||||||
int seeds[][RANK_NB] = { { 8977, 44560, 54343, 38998, 5731, 95205, 104912, 17020 },
|
int seeds[][RANK_NB] = { { 8977, 44560, 54343, 38998, 5731, 95205, 104912, 17020 },
|
||||||
{ 728, 10316, 55013, 32803, 12281, 15100, 16645, 255 } };
|
{ 728, 10316, 55013, 32803, 12281, 15100, 16645, 255 } };
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ struct Magic {
|
||||||
Bitboard* attacks;
|
Bitboard* attacks;
|
||||||
unsigned shift;
|
unsigned shift;
|
||||||
|
|
||||||
/// looks up the index using the 'magic bitboards' approach.
|
// Compute the attack's index using the 'magic bitboards' approach
|
||||||
unsigned index(Bitboard occupied) const {
|
unsigned index(Bitboard occupied) const {
|
||||||
|
|
||||||
if (HasPext)
|
if (HasPext)
|
||||||
|
@ -241,8 +241,8 @@ template<> inline int distance<Rank>(Square x, Square y) { return distance(rank_
|
||||||
template<PieceType Pt>
|
template<PieceType Pt>
|
||||||
inline Bitboard attacks_bb(Square s, Bitboard occupied) {
|
inline Bitboard attacks_bb(Square s, Bitboard occupied) {
|
||||||
|
|
||||||
const Magic& M = Pt == ROOK ? RookMagics[s] : BishopMagics[s];
|
const Magic& m = Pt == ROOK ? RookMagics[s] : BishopMagics[s];
|
||||||
return M.attacks[M.index(occupied)];
|
return m.attacks[m.index(occupied)];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Bitboard attacks_bb(PieceType pt, Square s, Bitboard occupied) {
|
inline Bitboard attacks_bb(PieceType pt, Square s, Bitboard occupied) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue