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[]) {
|
||||
|
||||
// Optimal PRNG seeds to pick the correct magics in the shortest time
|
||||
int seeds[][RANK_NB] = { { 8977, 44560, 54343, 38998, 5731, 95205, 104912, 17020 },
|
||||
{ 728, 10316, 55013, 32803, 12281, 15100, 16645, 255 } };
|
||||
|
||||
|
|
|
@ -83,18 +83,18 @@ struct Magic {
|
|||
Bitboard* attacks;
|
||||
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 {
|
||||
|
||||
if (HasPext)
|
||||
return unsigned(pext(occupied, mask));
|
||||
if (HasPext)
|
||||
return unsigned(pext(occupied, mask));
|
||||
|
||||
if (Is64Bit)
|
||||
return unsigned(((occupied & mask) * magic) >> shift);
|
||||
if (Is64Bit)
|
||||
return unsigned(((occupied & mask) * magic) >> shift);
|
||||
|
||||
unsigned lo = unsigned(occupied) & unsigned(mask);
|
||||
unsigned hi = unsigned(occupied >> 32) & unsigned(mask >> 32);
|
||||
return (lo * unsigned(magic) ^ hi * unsigned(magic >> 32)) >> shift;
|
||||
unsigned lo = unsigned(occupied) & unsigned(mask);
|
||||
unsigned hi = unsigned(occupied >> 32) & unsigned(mask >> 32);
|
||||
return (lo * unsigned(magic) ^ hi * unsigned(magic >> 32)) >> shift;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -241,8 +241,8 @@ template<> inline int distance<Rank>(Square x, Square y) { return distance(rank_
|
|||
template<PieceType Pt>
|
||||
inline Bitboard attacks_bb(Square s, Bitboard occupied) {
|
||||
|
||||
const Magic& M = Pt == ROOK ? RookMagics[s] : BishopMagics[s];
|
||||
return M.attacks[M.index(occupied)];
|
||||
const Magic& m = Pt == ROOK ? RookMagics[s] : BishopMagics[s];
|
||||
return m.attacks[m.index(occupied)];
|
||||
}
|
||||
|
||||
inline Bitboard attacks_bb(PieceType pt, Square s, Bitboard occupied) {
|
||||
|
|
Loading…
Add table
Reference in a new issue