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

Evaluate every legal column from the current position and print one line per column: the column index and the perfect-play score that results from playing it.

Evaluate every legal column from the current position and print one line per column: the column index and the perfect-play score that results from playing it. Equivalent to what an analysis UI would do to surface candidate moves to a human.

#include <iostream>
#include "BitBully.h"
int main() {
b.play("4435"); // arbitrary mid-game position
const auto scores = solver.scoreMoves(b);
for (int col = 0; col < BitBully::Board::N_COLUMNS; ++col) {
if (b.isLegalMove(col)) {
std::cout << "col " << col << " -> " << scores[col] << '\n';
}
}
return 0;
}
Connect-4 search engine that operates on BitBully::Board.
Perfect-play Connect-4 solver.
Definition BitBully.h:45
auto scoreMoves(const Board &b, const int maxDepth=-1)
Evaluate every column move from b.
Definition BitBully.h:499
Connect-4 position represented as a pair of 64-bit bitboards.
Definition Board.h:204
bool isLegalMove(int column) const
Check whether dropping a stone in column is legal.
Definition Board.cpp:170
bool play(int column)
Drop a stone of the player to move into column.
Definition Board.cpp:137
static constexpr int N_COLUMNS
Number of columns in a Connect-4 grid.
Definition Board.h:211
int main(const int argc, const char *const argv[])
Entry point of the benchmark binary.
Definition main.cpp:108