diff options
| author | Adam <adammegarules1@gmail.com> | 2026-08-18 11:26:44 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-08-18 11:26:44 +0200 |
| commit | 419f931a8001ca1c8c5960d68ae6bdef53c76f16 (patch) | |
| tree | b6162a5d4324fb4df8e831aff3a1a869d794daca /src/bot.cpp | |
| parent | 8a3d56d5bb57b58fa60966edcec0b33d3c2d1041 (diff) | |
refactor(book): refactoring opening book code
Diffstat (limited to 'src/bot.cpp')
| -rw-r--r-- | src/bot.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
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 <vector> #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<uint16_t> bookMove = ProbeBook(hash); + if (bookMove.has_value()) { + return bookMove.value(); + } + } + // use depth INF if caller hasnt provided depth int actualDepth = maxDepth > 0 ? maxDepth : INF; |
