aboutsummaryrefslogtreecommitdiff
path: root/src/bot.cpp
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-08-01 14:04:21 +0200
committerAdam <adammegarules1@gmail.com>2026-08-01 14:04:21 +0200
commit69252d4de9b5cc9c27c7e4815277d577a13e1be1 (patch)
treebc490be745d8d5b9bd1f35ca7ce12228f9e11584 /src/bot.cpp
parentf56178ec9afdd89b85fc0284bddefa5b3f9515d1 (diff)
adding book usage
Diffstat (limited to 'src/bot.cpp')
-rw-r--r--src/bot.cpp10
1 files changed, 10 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;