X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.cpp;h=ff10b4ff7026524955953dc0d76806b3e32b2d3f;hp=bfacc4121a0312b2d2461239008344c940c3857f;hb=94b1bbb68be6b0bc3aaf1cb804841a022bcc7007;hpb=64d29a633066e39b62af5ee0bbf32645994744ec diff --git a/src/bitboard.cpp b/src/bitboard.cpp index bfacc412..ff10b4ff 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -149,7 +149,10 @@ const std::string Bitboards::pretty(Bitboard b) { void Bitboards::init() { for (Square s = SQ_A1; s <= SQ_H8; ++s) - BSFTable[bsf_index(SquareBB[s] = 1ULL << s)] = s; + { + SquareBB[s] = 1ULL << s; + BSFTable[bsf_index(SquareBB[s])] = s; + } for (Bitboard b = 1; b < 256; ++b) MS1BTable[b] = more_than_one(b) ? MS1BTable[b - 1] : lsb(b); @@ -279,7 +282,12 @@ namespace { b = size = 0; do { occupancy[size] = b; - reference[size++] = sliding_attack(deltas, s, b); + reference[size] = sliding_attack(deltas, s, b); + + if (HasPext) + attacks[s][_pext_u64(b, masks[s])] = reference[size]; + + size++; b = (b - masks[s]) & masks[s]; } while (b); @@ -288,12 +296,16 @@ namespace { if (s < SQ_H8) attacks[s + 1] = attacks[s] + size; + if (HasPext) + continue; + booster = MagicBoosters[Is64Bit][rank_of(s)]; // Find a magic for square 's' picking up an (almost) random number // until we find the one that passes the verification test. do { - do magics[s] = rk.magic_rand(booster); + do + magics[s] = rk.magic_rand(booster); while (popcount((magics[s] * masks[s]) >> 56) < 6); std::memset(attacks[s], 0, size * sizeof(Bitboard));