From 3fe79ab4972cd90005bfb641e546aea249e721c9 Mon Sep 17 00:00:00 2001 From: rektdie Date: Mon, 31 Mar 2025 01:14:57 +0200 Subject: [PATCH] made some extra structs and function --- source/datagen.cpp | 23 +++++++++++++++++++++++ source/datagen.h | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 source/datagen.cpp diff --git a/source/datagen.cpp b/source/datagen.cpp new file mode 100644 index 0000000..8f46e0e --- /dev/null +++ b/source/datagen.cpp @@ -0,0 +1,23 @@ +#include +#include "datagen.h" +#include "movegen.h" + +namespace DATAGEN { + +static void PlayRandMoves(Board &board) { + std::random_device dev; + std::mt19937 rng(dev()); + + for (int count = 0; count < RAND_MOVES; count++) { + MOVEGEN::GenerateMoves(board); + std::uniform_int_distribution dist(0, board.currentMoveIndex); + + bool isLegal = board.MakeMove(board.moveList[dist(rng)]); + if (!isLegal) count--; + } +} + +void Run() { + +} +} \ No newline at end of file diff --git a/source/datagen.h b/source/datagen.h index 9e149e2..c9093bb 100644 --- a/source/datagen.h +++ b/source/datagen.h @@ -2,14 +2,20 @@ #include "board.h" #include "utils.h" -struct PackedBoard { +namespace DATAGEN { + +constexpr int SOFT_NODES = 5000; +constexpr int HARD_NODES = 100000; +constexpr int RAND_MOVES = 8; + +struct MarlinFormat { uint64_t occupancy; // 8 bytes: Bitboard representing all occupied squares (includes all pieces) std::array pieces; // 32 bytes: 64 squares stored in 4-bit format (2 squares per byte) uint8_t stmEPSquare; // 1 byte: STM (side to move) in bit 7, EP square in bits 0-5 uint8_t halfmoveClock; // 1 byte: Halfmove counter for the 50-move rule (incremented after each move) uint16_t fullmoveNumber; // 2 bytes: Full move counter, starting at 1 (increments after Black's move) - int16_t eval; // 2 bytes: Static evaluation score (e.g., centipawns, positive = White advantage) - uint8_t wdl; // 1 byte: Win-Draw-Loss classification (for training or result storage) + int16_t eval; // 2 bytes: Search score (e.g., centipawns, positive = White advantage) + uint8_t wdl; // 1 byte: 0 = white loss, 1 = draw, 2 = white win uint8_t extra; // 1 byte: Reserved for future use or additional data void packFrom(Board& board, int16_t eval, uint8_t wdl) { @@ -23,3 +29,26 @@ struct PackedBoard { extra = 0; } }; + +struct ScoredMove { + uint16_t move; + int16_t score; + + ScoredMove(Move m, int s) { + move = m; + score = s; + } +}; + +struct Game { + MarlinFormat format; + std::vector moves; + + Game(MarlinFormat f, std::vector m) { + format = f; + moves = m; + } +}; + +void Run(); +} \ No newline at end of file