aboutsummaryrefslogtreecommitdiff
path: root/src/uci.cpp
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-07-29 19:55:22 +0200
committerAdam <adammegarules1@gmail.com>2026-07-29 19:55:22 +0200
commit4aac933e3c08535501558448ce43ce610b5e317f (patch)
treebfcf207dd7787d70e94017ed45f1af7e32106ade /src/uci.cpp
parent1e57de844a1524b776167ccd7a1e822677d62527 (diff)
adding depth support
Diffstat (limited to 'src/uci.cpp')
-rw-r--r--src/uci.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/uci.cpp b/src/uci.cpp
index 8a7ad9a..e6aec4e 100644
--- a/src/uci.cpp
+++ b/src/uci.cpp
@@ -9,7 +9,6 @@
#include <cctype>
#include <cstdint>
#include <iostream>
-#include <print>
#include <sstream>
#include <string>
@@ -126,11 +125,27 @@ void Uci() {
cout << "readyok\n";
cout.flush();
} else if (cmd.starts_with("go")) {
- Move best = EngineGetBestMove(&game);
+
+ stringstream ss(line);
+
+ string token;
+ int depth = 4; // default depth
+
+ ss >> token; // go
+
+ while (ss >> token) {
+ if (token == "depth") {
+ ss >> depth;
+ break;
+ }
+ }
+
+ Move best = EngineGetBestMove(&game, depth);
cout << "bestmove ";
cout << (char)(best.From.file + 'a') << 8 - best.From.rank
<< (char)(best.To.file + 'a') << 8 - best.To.rank;
+
if (best.promotion != NONEPIECE) {
switch (best.promotion) {
case QUEEN:
@@ -146,10 +161,11 @@ void Uci() {
cout << "b";
break;
default:
- assert(false && "Unexepted promotion type");
+ assert(false && "Unexpected promotion type");
}
}
- println();
+
+ cout << "\n";
SaveTranspositionTable(transpositions);
cout.flush();
} else if (cmd.starts_with("position")) {