From 419f931a8001ca1c8c5960d68ae6bdef53c76f16 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 18 Aug 2026 11:26:44 +0200 Subject: refactor(book): refactoring opening book code --- src/bot.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/bot.cpp') diff --git a/src/bot.cpp b/src/bot.cpp index 7b937bd..99f60aa 100644 --- a/src/bot.cpp +++ b/src/bot.cpp @@ -12,6 +12,7 @@ #include #include "board/board.hpp" +#include "book.hpp" #include "bot.hpp" #include "evaluate.hpp" #include "moves.hpp" @@ -19,6 +20,7 @@ constexpr int DEFAULT_TIME = 7; constexpr int Q_DEPTH_LIMIT = 4; +constexpr int BOOK_DEPTH = 100; constexpr int MATE = 10000; @@ -320,6 +322,15 @@ uint16_t GetBestMove(Game *b, int maxDepth, move_options options) { searchStopped = false; Nodes = 0; + uint64_t hash = GenerateZobristKey(b); + + if (b->MoveClock <= BOOK_DEPTH) { + std::optional bookMove = ProbeBook(hash); + if (bookMove.has_value()) { + return bookMove.value(); + } + } + // use depth INF if caller hasnt provided depth int actualDepth = maxDepth > 0 ? maxDepth : INF; -- cgit v1.2.3