From eda51f19a2c1c5feeb755b6877132738ce1b1771 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Mon, 5 Apr 2021 16:15:37 +0200 Subject: [PATCH] Add king square counter --- src/learn/stats.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/learn/stats.cpp b/src/learn/stats.cpp index ce85caa0..419108d9 100644 --- a/src/learn/stats.cpp +++ b/src/learn/stats.cpp @@ -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(WHITE)] += 1; + m_black[pos.square(BLACK)] += 1; + } + + void reset() override + { + m_white = StatPerSquare{}; + m_black = StatPerSquare{}; + } + + private: + StatPerSquare m_white; + StatPerSquare 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("position_count"); + reg.add("king"); + reg.add("king_square_count"); + return reg; }();