LCOV - code coverage report
Current view: top level - Source/nnue/learn - learn_tools.hpp (source / functions) Coverage Total Hit
Test: coverage Lines: 0.0 % 7 0
Test Date: 2026-03-02 16:42:41 Functions: - 0 0

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include "definition.hpp"
       4              : 
       5              : #if defined(WITH_DATA2BIN)
       6              : 
       7              : #include <cmath>
       8              : #include <cstdint>
       9              : #include <filesystem>
      10              : #include <string>
      11              : #include <vector>
      12              : 
      13              : struct Position;
      14              : 
      15              : // For Minic data generation and use to stay compatible with SF one,
      16              : // I need to handle SF move encoding in the binary format ...
      17              : // So here is some SF extracted Move usage things
      18              : namespace FromSF {
      19              : 
      20              : enum MoveType { NORMAL, PROMOTION = 1 << 14, ENPASSANT = 2 << 14, CASTLING = 3 << 14 };
      21              : 
      22              : template<MoveType T> constexpr MiniMove MakeMove(const Square from, const Square to, const Piece prom = P_wn) {
      23            0 :    return static_cast<MiniMove>(T + ((prom - P_wn) << 12) + (from << 6) + to);
      24              : }
      25              : 
      26            0 : constexpr MiniMove MakeMoveStd(const Square from, const Square to) { return static_cast<MiniMove>((from << 6) + to); }
      27              : 
      28            0 : constexpr Square from_sq(const Move m) { return static_cast<Square>((m >> 6) & 0x3F); }
      29              : 
      30            0 : constexpr Square to_sq(const Move m) { return static_cast<Square>(m & 0x3F); }
      31              : 
      32            0 : constexpr MoveType type_of(const Move m) { return static_cast<MoveType>(m & (3 << 14)); }
      33              : 
      34            0 : constexpr Piece promotion_type(const Move m) { return static_cast<Piece>(((m >> 12) & 3) + P_wn); }
      35              : 
      36              : } // namespace FromSF
      37              : 
      38              : struct PackedSfen {
      39              :    uint8_t data[32];
      40              : };
      41              : 
      42            0 : struct PackedSfenValue {
      43              :    // phase
      44              :    PackedSfen sfen;
      45              : 
      46              :    // Evaluation value returned from Learner::search()
      47              :    int16_t score;
      48              : 
      49              :    // PV first move
      50              :    // Used when finding the match rate with the teacher
      51              :    uint16_t move;
      52              : 
      53              :    // Trouble of the phase from the initial phase.
      54              :    uint16_t gamePly;
      55              : 
      56              :    // 1 if the player on this side ultimately wins the game. -1 if you are losing.
      57              :    // 0 if a draw is reached.
      58              :    // The draw is in the teacher position generation command gensfen,
      59              :    // Only write if LEARN_GENSFEN_DRAW_RESULT is enabled.
      60              :    int8_t game_result;
      61              : 
      62              :    // When exchanging the file that wrote the teacher aspect with other people
      63              :    //Because this structure size is not fixed, pad it so that it is 40 bytes in any environment.
      64              :    uint8_t padding = 0;
      65              : 
      66              :    // 32 + 2 + 2 + 2 + 1 + 1 = 40bytes
      67              : };
      68              : 
      69              : void sfen_pack(const Position& p, PackedSfen& sfen);
      70              : 
      71              : int set_from_packed_sfen(Position& p, PackedSfen& sfen);
      72              : 
      73              : MiniMove ToSFMove(const Position& p, const Square from, const Square to, const MType type);
      74              : 
      75              : MiniMove FromSFMove(const Position& p, const MiniMove sfmove);
      76              : 
      77              : #endif // WITH_DATA2BIN
        

Generated by: LCOV version 2.0-1