BitBully 0.0.78
A fast, perfect-play Connect-4 engine in modern C++
Loading...
Searching...
No Matches
with_opening_book.cpp

Demonstrates loading an 8-ply opening book at construction time and letting the solver short-circuit early-game positions that are already resolved in the book.

Demonstrates loading an 8-ply opening book at construction time and letting the solver short-circuit early-game positions that are already resolved in the book. If the book file is missing the example still works; it just performs the full search.

#include <filesystem>
#include <iostream>
#include "BitBully.h"
int main() {
// Path is relative to wherever the binary is launched from.
const std::filesystem::path bookPath = "openingbook_8ply.bin";
BitBully::BitBully solver{bookPath};
if (!solver.isBookLoaded()) {
std::cerr << "(book not found, falling back to full search)\n";
}
BitBully::Board b; // empty starting position
const int score = solver.mtdf(b, /*firstGuess=*/0);
std::cout << "score from start = " << score << '\n';
return 0;
}
Connect-4 search engine that operates on BitBully::Board.
Perfect-play Connect-4 solver.
Definition BitBully.h:45
bool isBookLoaded() const
Was an opening book successfully loaded?
Definition BitBully.h:72
int mtdf(const Board &b, const int firstGuess, const int maxDepth=-1) noexcept
Solve a position using the MTD(f) driver.
Definition BitBully.h:188
Connect-4 position represented as a pair of 64-bit bitboards.
Definition Board.h:204
int main(const int argc, const char *const argv[])
Entry point of the benchmark binary.
Definition main.cpp:108