From 5ad924f3c64a19e04a894cb75535641042704fd8 Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 2 Apr 2025 07:25:22 +0200 Subject: [PATCH] tried to implement viri move format --- source/datagen.cpp | 2 +- source/datagen.h | 2 +- source/move.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/source/datagen.cpp b/source/datagen.cpp index 8e7f7be..c2702cd 100644 --- a/source/datagen.cpp +++ b/source/datagen.cpp @@ -259,7 +259,7 @@ void Run(int targetPositions, int threads) { if (!results.bestMove) break; safeResults = results; - game.moves.push_back(ScoredMove(results.bestMove, results.score)); + game.moves.push_back(ScoredMove(results.bestMove.ConvertToViriMoveFormat(), results.score)); board.MakeMove(results.bestMove); MOVEGEN::GenerateMoves(board); diff --git a/source/datagen.h b/source/datagen.h index 684f71e..28003ea 100644 --- a/source/datagen.h +++ b/source/datagen.h @@ -59,7 +59,7 @@ struct ScoredMove { ScoredMove() : move(0), score(0) {} - ScoredMove(Move m, int s) { + ScoredMove(uint16_t m, int16_t s) { move = m; score = s; } diff --git a/source/move.h b/source/move.h index 6a0e7aa..f66ee2b 100644 --- a/source/move.h +++ b/source/move.h @@ -76,6 +76,48 @@ public: } } + uint16_t ConvertToViriMoveFormat() { + uint16_t viriMove = 0; + int flags = GetFlags(); + + // Set from and to squares (6 bits each) + viriMove |= MoveFrom(); + viriMove |= MoveTo() << 6; + + // Determine move type (bits 12-13) + uint16_t moveType = 0; + uint16_t promoPiece = 0; + + if (flags == kingCastle || flags == queenCastle) { + moveType = 1; // Castling + } + else if (flags == epCapture) { + moveType = 2; // En passant + } + else if (flags >= knightPromotion && flags <= queenPromoCapture) { + moveType = 3; // Promotion + // Set promo piece (bits 14-15) + if (flags == knightPromotion || flags == knightPromoCapture) { + promoPiece = 0; // Knight + } + else if (flags == bishopPromotion || flags == bishopPromoCapture) { + promoPiece = 1; // Bishop + } + else if (flags == rookPromotion || flags == rookPromoCapture) { + promoPiece = 2; // Rook + } + else if (flags == queenPromotion || flags == queenPromoCapture) { + promoPiece = 3; // Queen + } + } + // else moveType remains 0 (normal move) + + viriMove |= moveType << 12; + viriMove |= promoPiece << 14; + + return viriMove; + } + operator uint16_t() { return m_move; }