mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-24 19:16:49 +08:00
Per square stats utility
This commit is contained in:
@@ -11,12 +11,15 @@
|
||||
|
||||
#include "nnue/evaluate_nnue.h"
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
@@ -74,6 +77,44 @@ namespace Learner::Stats
|
||||
std::map<std::string, std::vector<std::unique_ptr<StatisticGathererFactoryBase>>> m_gatherers_by_group;
|
||||
};
|
||||
|
||||
/*
|
||||
Statistic gatherer helpers
|
||||
*/
|
||||
|
||||
template <typename T>
|
||||
struct StatPerSquare
|
||||
{
|
||||
StatPerSquare()
|
||||
{
|
||||
for (int i = 0; i < SQUARE_NB; ++i)
|
||||
m_squares[i] = 0;
|
||||
}
|
||||
|
||||
[[nodiscard]] T& operator[](Square sq)
|
||||
{
|
||||
return m_squares[sq];
|
||||
}
|
||||
|
||||
[[nodiscard]] const T& operator[](Square sq) const
|
||||
{
|
||||
return m_squares[sq];
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string get_formatted_stats() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
for (int i = 0; i < SQUARE_NB; ++i)
|
||||
{
|
||||
ss << std::setw(8) << m_squares[i] << ' ';
|
||||
if ((i + 1) % 8 == 0)
|
||||
ss << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::array<T, SQUARE_NB> m_squares;
|
||||
};
|
||||
|
||||
/*
|
||||
Definitions for specific statistic gatherers follow:
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user