mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-23 02:27:00 +08:00
Simplify lookup_count and clean up pieces().
https://github.com/official-stockfish/Stockfish/pull/4656 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
8634717c64
commit
80564bcfcd
@@ -24,6 +24,7 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <type_traits>
|
||||
#include "../nnue_common.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 = [](){
|
||||
std::array<unsigned, 256> v;
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
int j = i;
|
||||
int k = 0;
|
||||
while(j)
|
||||
{
|
||||
j &= j - 1;
|
||||
++k;
|
||||
}
|
||||
v[i] = k;
|
||||
}
|
||||
v[i] = unsigned(std::bitset<8>(i).count());
|
||||
return v;
|
||||
}();
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
std::string fen() const;
|
||||
|
||||
// Position representation
|
||||
Bitboard pieces(PieceType pt) const;
|
||||
Bitboard pieces(PieceType pt = ALL_PIECES) const;
|
||||
template<typename ...PieceTypes> Bitboard pieces(PieceType pt, PieceTypes... pts) const;
|
||||
Bitboard pieces(Color c) 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));
|
||||
}
|
||||
|
||||
inline Bitboard Position::pieces(PieceType pt = ALL_PIECES) const {
|
||||
inline Bitboard Position::pieces(PieceType pt) const {
|
||||
return byTypeBB[pt];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user