aboutsummaryrefslogtreecommitdiff
path: root/src/uci.cpp
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-08-17 20:01:05 +0200
committerAdam <adammegarules1@gmail.com>2026-08-17 20:01:05 +0200
commitc5891a499f180da91aa14ad7273f00092a7b3e45 (patch)
tree4af50ef60979368a298940732e86c9ea7786c2c4 /src/uci.cpp
parent11e2da3df8a4bf598f630dbad8bb666047c22bce (diff)
adding zobrist hashing
Diffstat (limited to 'src/uci.cpp')
-rw-r--r--src/uci.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/uci.cpp b/src/uci.cpp
index 6c035d5..23e8419 100644
--- a/src/uci.cpp
+++ b/src/uci.cpp
@@ -14,6 +14,7 @@
#include "board/board.hpp"
#include "board/fen.hpp"
#include "bot.hpp"
+#include "book.hpp"
#include "misc.hpp"
#include "moves.hpp"
#include "uci.hpp"
@@ -222,13 +223,25 @@ static void GoCommand(Game *game, std::string &cmd) {
std::cout << "Fatal: Depth must be positive integer";
exit(1);
}
- move_options options = {
- .wtime = wtime,
- .btime = btime,
- .wncr = wncr,
- .bncr = bncr,
- };
- uint16_t best = GetBestMove(game, depth, options);
+
+ // Try opening book first
+ uint16_t bookMove = 0;
+ if (game->MoveClock < GetBookDepth()) {
+ bookMove = ProbeBook(GenerateZobristKey(game));
+ }
+
+ uint16_t best;
+ if (bookMove != 0) {
+ best = bookMove;
+ } else {
+ move_options options = {
+ .wtime = wtime,
+ .btime = btime,
+ .wncr = wncr,
+ .bncr = bncr,
+ };
+ best = GetBestMove(game, depth, options);
+ }
Piece piece = game->pieces[getFromValueFromMove(best)];
@@ -309,6 +322,8 @@ void Uci() {
Game game = initBoard(starting_fen, &transpositions);
std::string cmd;
+ InitBook("book.bin");
+
while (getline(std::cin, cmd)) {
if (cmd == "quit") {
return;
@@ -342,5 +357,9 @@ void Uci() {
if (cmd == "moves") {
movesCommnad(&game);
}
+ if (cmd == "hash") {
+ uint64_t hash = GenerateZobristKey(&game);
+ std::cout << hash << "\n";
+ }
}
}