-/// piece of type Pt (bishop or rook) placed on 's'. The helper magic_index()
-/// looks up the index using the 'magic bitboards' approach.
-inline unsigned magic_index(const Magic& m, Bitboard occupied) {
-
- if (HasPext)
- return unsigned(pext(occupied, m.mask));
-
- if (Is64Bit)
- return unsigned(((occupied & m.mask) * m.magic) >> m.shift);
-
- unsigned lo = unsigned(occupied) & unsigned(m.mask);
- unsigned hi = unsigned(occupied >> 32) & unsigned(m.mask >> 32);
- return (lo * unsigned(m.magic) ^ hi * unsigned(m.magic >> 32)) >> m.shift;
-}