mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 09:13:08 +00:00
Simplify lookup_count and clean up pieces().
https://github.com/official-stockfish/Stockfish/pull/4656 No functional change
This commit is contained in:
parent
8634717c64
commit
80564bcfcd
2 changed files with 4 additions and 12 deletions
|
@ -24,6 +24,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <bitset>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include "../nnue_common.h"
|
#include "../nnue_common.h"
|
||||||
#include "affine_transform.h"
|
#include "affine_transform.h"
|
||||||
|
@ -77,16 +78,7 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||||
alignas(CacheLineSize) static inline const std::array<unsigned, 256> lookup_count = [](){
|
alignas(CacheLineSize) static inline const std::array<unsigned, 256> lookup_count = [](){
|
||||||
std::array<unsigned, 256> v;
|
std::array<unsigned, 256> v;
|
||||||
for (int i = 0; i < 256; ++i)
|
for (int i = 0; i < 256; ++i)
|
||||||
{
|
v[i] = unsigned(std::bitset<8>(i).count());
|
||||||
int j = i;
|
|
||||||
int k = 0;
|
|
||||||
while(j)
|
|
||||||
{
|
|
||||||
j &= j - 1;
|
|
||||||
++k;
|
|
||||||
}
|
|
||||||
v[i] = k;
|
|
||||||
}
|
|
||||||
return v;
|
return v;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ public:
|
||||||
std::string fen() const;
|
std::string fen() const;
|
||||||
|
|
||||||
// Position representation
|
// Position representation
|
||||||
Bitboard pieces(PieceType pt) const;
|
Bitboard pieces(PieceType pt = ALL_PIECES) const;
|
||||||
template<typename ...PieceTypes> Bitboard pieces(PieceType pt, PieceTypes... pts) const;
|
template<typename ...PieceTypes> Bitboard pieces(PieceType pt, PieceTypes... pts) const;
|
||||||
Bitboard pieces(Color c) const;
|
Bitboard pieces(Color c) const;
|
||||||
template<typename ...PieceTypes> Bitboard pieces(Color c, PieceTypes... pts) const;
|
template<typename ...PieceTypes> Bitboard pieces(Color c, PieceTypes... pts) const;
|
||||||
|
@ -224,7 +224,7 @@ inline Piece Position::moved_piece(Move m) const {
|
||||||
return piece_on(from_sq(m));
|
return piece_on(from_sq(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Bitboard Position::pieces(PieceType pt = ALL_PIECES) const {
|
inline Bitboard Position::pieces(PieceType pt) const {
|
||||||
return byTypeBB[pt];
|
return byTypeBB[pt];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue