aboutsummaryrefslogtreecommitdiff
path: root/src/uci.cpp
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-08-24 10:30:53 +0200
committerAdam <adammegarules1@gmail.com>2026-08-24 10:30:53 +0200
commit22718aea57fde4e325aea4c0d36d76b0d1609fa7 (patch)
treee01eb8fc249601b95a3ee7da601c62d271d43e5c /src/uci.cpp
parent9a9cbe07f062ce7734ae2b7c6161c0e8ec4b0e4c (diff)
refactor(tests): improving tests by creating testing cli app
Diffstat (limited to 'src/uci.cpp')
-rw-r--r--src/uci.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/uci.cpp b/src/uci.cpp
index 7cff997..5f62169 100644
--- a/src/uci.cpp
+++ b/src/uci.cpp
@@ -1,6 +1,7 @@
#include <array>
#include <cassert>
#include <cctype>
+#include <chrono>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
@@ -351,5 +352,35 @@ void Uci() {
uint64_t hash = GenerateHashFromScratch(&game);
std::cout << hash << "\n";
}
+ if (cmd.starts_with("perft")) {
+
+ uint32_t depth = 0;
+
+ std::stringstream ss(cmd);
+ std::string token;
+
+ ss >> token; // position
+
+ ss >> depth;
+
+ auto start = std::chrono::steady_clock::now();
+
+ uint64_t count = 0;
+
+#ifdef PERFT_DIVIDE
+ count = MoveGenTestDivide(depth, &game);
+#else
+ count = MoveGenTest(depth, &game);
+#endif
+
+ auto end = std::chrono::steady_clock::now();
+ auto ms =
+ std::chrono::duration_cast<std::chrono::milliseconds>(end - start)
+ .count();
+ std::ostringstream oss;
+ oss << "{\"ms\": " << ms << ", \"result\": " << count << "}";
+
+ std::cout << oss.str() << "\n";
+ }
}
}