BitBully 0.0.78
A fast, perfect-play Connect-4 engine in modern C++
Loading...
Searching...
No Matches
quick_solve.cpp
1
11#include <iostream>
12
13#include "BitBully.h"
14
15int main() {
17 if (!b.play("4435")) {
18 std::cerr << "Illegal move sequence\n";
19 return 1;
20 }
21
22 BitBully::BitBully solver;
23 const int score = solver.mtdf(b, /*firstGuess=*/0);
24 const int plies = BitBully::BitBully::scoreToMovesLeft(score, b);
25
26 std::cout << b.toString();
27 std::cout << "score = " << score << " (plies until end = " << plies << ")\n";
28 return 0;
29}
Connect-4 search engine that operates on BitBully::Board.
Perfect-play Connect-4 solver.
Definition BitBully.h:45
static int scoreToMovesLeft(const int score, const Board &b) noexcept
Convert a solver score to the number of moves until the game ends.
Definition BitBully.h:115
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