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

BitBully is a high-performance perfect-play Connect-4 solver written in modern C++. It reaches every win/loss/draw verdict for any position by combining a bitboard representation, a hand-tuned alpha-beta negamax, a transposition table and pre-computed opening books.

This documentation covers the C++ core of the project.

BitBully

Library at a glance

Component Header Purpose
BitBully::Board Board.h Bitboard position with legal-move generation
BitBully::BitBully BitBully.h Negamax + MTD(f) solver driver
BitBully::TranspositionTable TranspositionTable.h Direct-mapped score cache
BitBully::OpeningBook OpeningBook.h 8-/12-ply opening database loader
BitBully::MoveList MoveList.h Tiny priority queue used for move ordering

Quick example

#include "BitBully.h"
int main() {
BitBully::Board b; // empty starting position
if (!b.play("4435")) { // play a few moves (column indices)
return 1;
}
std::cout << b.toString() << '\n';
BitBully::BitBully solver; // create the search engine
const int score = solver.mtdf(b, /*firstGuess=*/0);
std::cout << "score = " << score << '\n';
return 0;
}
Connect-4 search engine that operates on BitBully::Board.
Perfect-play Connect-4 solver.
Definition BitBully.h:45
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
bool play(int column)
Drop a stone of the player to move into column.
Definition Board.cpp:137
std::string toString() const
Pretty-printed ASCII representation of the board.
Definition Board.cpp:481
int main(const int argc, const char *const argv[])
Entry point of the benchmark binary.
Definition main.cpp:108

The score follows the convention introduced by Pascal Pons: positive means the side to move wins, negative means it loses, and 0 is a draw. Use BitBully::BitBully::scoreToMovesLeft to translate the compact score into the actual number of plies remaining.


Where to go next