From ad04f16e478357633c08174e844c8756f7892a32 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 17 Aug 2026 15:22:37 +0200 Subject: refactor(board): refactoring move generation code into better and nice way + adding debug command moves --- src/uci.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/uci.cpp') diff --git a/src/uci.cpp b/src/uci.cpp index b98e6ce..6c035d5 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -286,6 +286,24 @@ static void positionCommnad(Game *game, std::string &cmd) { MakeMove(move, game); } } +static void movesCommnad(Game *g) { + auto moves = GetLegalMoves(g, ALL); + for (auto move : moves) { + Piece piece = g->pieces[getFromValueFromMove(move)]; + + Position from = IndexToPosition(getFromValueFromMove(move)); + Position to = IndexToPosition(getToValueFromMove(move)); + PieceType promotion = getPromotionTypeFromMove(move); + + std::cout << static_cast(from.file + 'a') << 1 + from.rank + << static_cast(to.file + 'a') << 1 + to.rank; + std::cout << "\n"; + + if ((to.rank == 0 || to.rank == 7) && piece.type == PAWN) { + printPromotionLetter(promotion); + } + } +}; void Uci() { std::unordered_map transpositions = {}; Game game = initBoard(starting_fen, &transpositions); @@ -321,5 +339,8 @@ void Uci() { if (cmd.starts_with("position")) { positionCommnad(&game, cmd); } + if (cmd == "moves") { + movesCommnad(&game); + } } } -- cgit v1.2.3