diff options
| author | Adam <adammegarules1@gmail.com> | 2026-08-01 14:04:21 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-08-01 14:04:21 +0200 |
| commit | 69252d4de9b5cc9c27c7e4815277d577a13e1be1 (patch) | |
| tree | bc490be745d8d5b9bd1f35ca7ce12228f9e11584 | |
| parent | f56178ec9afdd89b85fc0284bddefa5b3f9515d1 (diff) | |
adding book usage
| -rw-r--r-- | src/bot.cpp | 10 | ||||
| -rw-r--r-- | src/opening_book.cpp | 3 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/bot.cpp b/src/bot.cpp index 02dfd22..193e487 100644 --- a/src/bot.cpp +++ b/src/bot.cpp @@ -2,6 +2,7 @@ #include "board/board.hpp" #include "evaluate.hpp" #include "moves.hpp" +#include "opening_book.hpp" #include "zobrist.hpp" #include <algorithm> @@ -251,6 +252,10 @@ static void PrintInfo(const int depth, const int engineScore, Move GetBestMove(Game *b, const int maxDepth) { Nodes = 0; + + Polyglot_Book book; + book.Load("book.bin"); + int actualDepth = maxDepth > 0 ? maxDepth : MAXIMUM_DEPTH; bool usingDefaultDepth = actualDepth == MAXIMUM_DEPTH; auto legalMoves = GetSortedLegalMoves(b, true, nullptr); @@ -268,6 +273,11 @@ Move GetBestMove(Game *b, const int maxDepth) { int depth = 1; while (continueSearching) { + if (book.HasMove(*b)) { + bestMove = book.GetMove(*b); + continueSearching = false; + break; + } SearchResult result = SearchDepth(b, depth, &bestMove); bestMove = result.bestMove; diff --git a/src/opening_book.cpp b/src/opening_book.cpp index e69de29..3c3af9b 100644 --- a/src/opening_book.cpp +++ b/src/opening_book.cpp @@ -0,0 +1,3 @@ +#include "opening_book.hpp" + +// todo implement |
