aboutsummaryrefslogtreecommitdiff
path: root/src/bot.cpp
diff options
context:
space:
mode:
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;