From d290c25ac246b6d32f35dfcd18481877d35bfaed Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 4 Aug 2026 08:03:45 +0200 Subject: fixing bug and todos --- src/uci.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/uci.cpp') diff --git a/src/uci.cpp b/src/uci.cpp index ffab5bc..37a68b8 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -40,14 +40,40 @@ using namespace std; Move UciToMove(const string uci) { Position from; Position to; + PieceType promotion = NONEPIECE; + if (uci.length() != 4 && uci.length() != 5) { + assert(false && "expected valid uci string"); + std::cout << "expected valid uci string\n"; + exit(1); + } from.file = static_cast(uci[0] - 'a'); from.rank = static_cast(uci[1] - '1'); to.file = static_cast(uci[2] - 'a'); to.rank = static_cast(uci[3] - '1'); + if (uci.length() == 5) { + switch (toupper(static_cast(uci[4]))) { + case 'Q': + promotion = QUEEN; + break; + case 'N': + promotion = KNIGHT; + break; + case 'R': + promotion = ROOK; + break; + case 'B': + promotion = BISHOP; + break; + default: + assert(false && "Unexpected promotion type"); + cout << "Unexpected promotion type"; + exit(1); + } + } - return {from, to}; + return {from, to, promotion}; } Game initBoard( @@ -89,7 +115,6 @@ static void PrintBitboard(uint64_t bb, const std::string &name) { std::printf(" | %d\n", 8 - rank); } - std::cout << " a b c d e f g h\n"; std::cout << "0x" << std::hex << bb << std::dec << "\n\n"; } -- cgit v1.2.3