A handful of recipes for the most common solver tasks.
Evaluating a position
const int score = solver.
mtdf(b, 0);
std::cout << "score = " << score
<< ", plies left = "
Connect-4 search engine that operates on BitBully::Board.
Perfect-play Connect-4 solver.
static int scoreToMovesLeft(const int score, const Board &b) noexcept
Convert a solver score to the number of moves until the game ends.
int mtdf(const Board &b, const int firstGuess, const int maxDepth=-1) noexcept
Solve a position using the MTD(f) driver.
Connect-4 position represented as a pair of 64-bit bitboards.
bool play(int column)
Drop a stone of the player to move into column.
Ranking all candidate moves
std::cout << "column " << c << ": " << scores[c] << '\n';
}
auto scoreMoves(const Board &b, const int maxDepth=-1)
Evaluate every column move from b.
static constexpr int N_COLUMNS
Number of columns in a Connect-4 grid.
Illegal moves receive the sentinel score -1000.
Loading an opening book
std::cerr << "could not load book\n";
}
bool isBookLoaded() const
Was an opening book successfully loaded?
BitBully infers the book flavour (8-/12-ply, with or without distance-to-mate) from the file size.
Calling the engine from Python
from bitbully import BitBully, Board
b = Board()
b.play("4435")
print(solver.mtdf(b, 0))
Top-level namespace for the BitBully Connect-4 engine.