diff options
| author | Adam <adammegarules1@gmail.com> | 2026-08-17 15:22:37 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-08-17 15:22:37 +0200 |
| commit | ad04f16e478357633c08174e844c8756f7892a32 (patch) | |
| tree | 6e1ca98dfa67584e86346bfe36c5d98ff6d59b3c /src/uci.cpp | |
| parent | 26c0c08b1c4fb302db55355bd49181c8740b7ee6 (diff) | |
refactor(board): refactoring move generation code into better and nice way + adding debug command moves
Diffstat (limited to 'src/uci.cpp')
| -rw-r--r-- | src/uci.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
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<char>(from.file + 'a') << 1 + from.rank + << static_cast<char>(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<uint64_t, TranspositionsEntry> 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); + } } } |
