Skip to content

Commit

Permalink
Indentation fix in index()
Browse files Browse the repository at this point in the history
No functional change.

Closes official-stockfish#1158
  • Loading branch information
mcostalba authored and zamar committed Jul 3, 2017
1 parent 6d24ef8 commit c0cb713
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/bitboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 } };

Expand Down
20 changes: 10 additions & 10 deletions src/bitboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c0cb713

Please sign in to comment.