From 69252d4de9b5cc9c27c7e4815277d577a13e1be1 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 1 Aug 2026 14:04:21 +0200 Subject: adding book usage --- src/bot.cpp | 10 ++++++++++ src/opening_book.cpp | 3 +++ 2 files changed, 13 insertions(+) (limited to 'src') 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 @@ -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 -- cgit v1.2.3