From c0cb713a000ef176cdad16defe640b7b6432a4a9 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 1 Jul 2017 07:58:38 +0200 Subject: [PATCH] Indentation fix in index() No functional change. Closes #1158 --- src/bitboard.cpp | 1 + src/bitboard.h | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 04d12c5e..e3c9140d 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -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 } }; diff --git a/src/bitboard.h b/src/bitboard.h index 9aa33750..e390b018 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -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(Square x, Square y) { return distance(rank_ template 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) { -- 2.39.2