aboutsummaryrefslogtreecommitdiff
path: root/src/uci.cpp
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-08-04 08:03:45 +0200
committerAdam <adammegarules1@gmail.com>2026-08-04 08:03:45 +0200
commitd290c25ac246b6d32f35dfcd18481877d35bfaed (patch)
treea1ace686498da077a653eb8799b4875338e03e55 /src/uci.cpp
parent27e879c62ecc019591201b1b1068b0c41870cfab (diff)
fixing bug and todos
Diffstat (limited to 'src/uci.cpp')
-rw-r--r--src/uci.cpp29
1 files changed, 27 insertions, 2 deletions
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<uint8_t>(uci[0] - 'a');
from.rank = static_cast<uint8_t>(uci[1] - '1');
to.file = static_cast<uint8_t>(uci[2] - 'a');
to.rank = static_cast<uint8_t>(uci[3] - '1');
+ if (uci.length() == 5) {
+ switch (toupper(static_cast<char>(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";
}