io-chess
UCI chess engine
Loading...
Searching...
No Matches
PolyglotBook Class Reference

Manages loading and probing of Polyglot opening books. More...

#include <polyglot_book.hpp>

Public Member Functions

 PolyglotBook (const std::string &book_path)
 Constructs a PolyglotBook instance.
 ~PolyglotBook ()
bool load ()
 Loads the book into memory.
chess::Move probe (const chess::Board &board, const std::string &bookName="Book")
 Probes the book for a move matching the current board state.

Private Member Functions

uint64_t compute_polyglot_key (const chess::Board &board) const
chess::Move polyglot_to_move (uint16_t poly_move, const chess::Board &board) const

Private Attributes

std::string book_path_
std::vector< PolyglotEntryentries_

Detailed Description

Manages loading and probing of Polyglot opening books.

Constructor & Destructor Documentation

◆ PolyglotBook()

PolyglotBook::PolyglotBook ( const std::string & book_path)

Constructs a PolyglotBook instance.

Parameters
book_pathFile path to the Polyglot (.bin) file.

◆ ~PolyglotBook()

PolyglotBook::~PolyglotBook ( )

Member Function Documentation

◆ compute_polyglot_key()

uint64_t PolyglotBook::compute_polyglot_key ( const chess::Board & board) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load()

bool PolyglotBook::load ( )

Loads the book into memory.

Returns
true if successful, false if the file could not be read.

◆ polyglot_to_move()

chess::Move PolyglotBook::polyglot_to_move ( uint16_t poly_move,
const chess::Board & board ) const
private
Here is the caller graph for this function:

◆ probe()

chess::Move PolyglotBook::probe ( const chess::Board & board,
const std::string & bookName = "Book" )

Probes the book for a move matching the current board state.

Moves are selected probabilistically based on their relative weights.

Parameters
boardThe chess board to probe.
bookNameOptional name for logging purposes.
Returns
The selected move, or NO_MOVE if no match is found.
Here is the call graph for this function:

Member Data Documentation

◆ book_path_

std::string PolyglotBook::book_path_
private

◆ entries_

std::vector<PolyglotEntry> PolyglotBook::entries_
private

The documentation for this class was generated from the following files: