mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Implement PEXT based attacks
According to: https://chessprogramming.wikispaces.com/BMI2#PEXTBitboards No functional change.
This commit is contained in:
parent
2bfe61c33b
commit
c556fe1d71
3 changed files with 18 additions and 1 deletions
|
@ -296,7 +296,12 @@ namespace {
|
||||||
b = size = 0;
|
b = size = 0;
|
||||||
do {
|
do {
|
||||||
occupancy[size] = b;
|
occupancy[size] = b;
|
||||||
reference[size++] = sliding_attack(deltas, s, b);
|
reference[size] = sliding_attack(deltas, s, b);
|
||||||
|
|
||||||
|
if (HasPext)
|
||||||
|
attacks[s][pext(occupancy[size], masks[s])] = reference[size];
|
||||||
|
|
||||||
|
size++;
|
||||||
b = (b - masks[s]) & masks[s];
|
b = (b - masks[s]) & masks[s];
|
||||||
} while (b);
|
} while (b);
|
||||||
|
|
||||||
|
@ -305,6 +310,9 @@ namespace {
|
||||||
if (s < SQ_H8)
|
if (s < SQ_H8)
|
||||||
attacks[s + 1] = attacks[s] + size;
|
attacks[s + 1] = attacks[s] + size;
|
||||||
|
|
||||||
|
if (HasPext)
|
||||||
|
continue;
|
||||||
|
|
||||||
booster = MagicBoosters[Is64Bit][rank_of(s)];
|
booster = MagicBoosters[Is64Bit][rank_of(s)];
|
||||||
|
|
||||||
// Find a magic for square 's' picking up an (almost) random number
|
// Find a magic for square 's' picking up an (almost) random number
|
||||||
|
|
|
@ -243,6 +243,9 @@ FORCE_INLINE unsigned magic_index(Square s, Bitboard occ) {
|
||||||
Bitboard* const Magics = Pt == ROOK ? RMagics : BMagics;
|
Bitboard* const Magics = Pt == ROOK ? RMagics : BMagics;
|
||||||
unsigned* const Shifts = Pt == ROOK ? RShifts : BShifts;
|
unsigned* const Shifts = Pt == ROOK ? RShifts : BShifts;
|
||||||
|
|
||||||
|
if (HasPext)
|
||||||
|
return unsigned(pext(occ, Masks[s]));
|
||||||
|
|
||||||
if (Is64Bit)
|
if (Is64Bit)
|
||||||
return unsigned(((occ & Masks[s]) * Magics[s]) >> Shifts[s]);
|
return unsigned(((occ & Masks[s]) * Magics[s]) >> Shifts[s]);
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,12 @@ const bool HasPopCnt = true;
|
||||||
const bool HasPopCnt = false;
|
const bool HasPopCnt = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_PEXT
|
||||||
|
const bool HasPext = true;
|
||||||
|
#else
|
||||||
|
const bool HasPext = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef IS_64BIT
|
#ifdef IS_64BIT
|
||||||
const bool Is64Bit = true;
|
const bool Is64Bit = true;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Reference in a new issue