mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-24 19:16:49 +08:00
Add king square counter
This commit is contained in:
@@ -147,6 +147,32 @@ namespace Learner::Stats
|
||||
std::uint64_t m_num_positions;
|
||||
};
|
||||
|
||||
struct KingSquareCounter : StatisticGathererBase
|
||||
{
|
||||
KingSquareCounter() :
|
||||
m_white{},
|
||||
m_black{}
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void on_position(const Position& pos) override
|
||||
{
|
||||
m_white[pos.square<KING>(WHITE)] += 1;
|
||||
m_black[pos.square<KING>(BLACK)] += 1;
|
||||
}
|
||||
|
||||
void reset() override
|
||||
{
|
||||
m_white = StatPerSquare<std::uint64_t>{};
|
||||
m_black = StatPerSquare<std::uint64_t>{};
|
||||
}
|
||||
|
||||
private:
|
||||
StatPerSquare<std::uint64_t> m_white;
|
||||
StatPerSquare<std::uint64_t> m_black;
|
||||
};
|
||||
|
||||
/*
|
||||
This function provides factories for all possible statistic gatherers.
|
||||
Each new statistic gatherer needs to be added there.
|
||||
@@ -158,6 +184,9 @@ namespace Learner::Stats
|
||||
|
||||
reg.add<PositionCounter>("position_count");
|
||||
|
||||
reg.add<KingSquareCounter>("king");
|
||||
reg.add<KingSquareCounter>("king_square_count");
|
||||
|
||||
return reg;
|
||||
}();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user