#pragma once #include "position.h" namespace rigby::nnue { // Value network trained with bullet on Lc0 data (see train/README.md): // (768 -> HIDDEN)x2 -> 1, SCReLU, dual perspective, quantised i16. constexpr int HIDDEN = 1024; constexpr int SCALE = 400; constexpr int QA = 255; constexpr int QB = 64; // The hidden layer before the activation, from white's and from black's point // of view. Kept up to date move by move along the quiescence search. struct Accumulator { alignas(64) i16 values[2][HIDDEN]; }; // Checks and loads the embedded network. Exits with a message if it does not fit. void init(); // Builds the accumulator of `pos` from scratch. void refresh(const Position& pos, Accumulator& acc); // The accumulator after `m`, from the one before it; `pos` is the position // before the move. Gives exactly what refresh would give for the new position. void update(const Accumulator& before, const Position& pos, Move m, Accumulator& after); // Evaluation in centipawns from the view of `stm`, on the network's scale: // sigmoid(cp / SCALE) is the expected score. int evaluate(const Accumulator& acc, int stm); // Same, building the accumulator from scratch. int evaluate(const Position& pos); } // namespace rigby::nnue