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

Benchmark driver comparing BitBully against Pascal Pons' Connect-4 solver. More...

#include <chrono>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <thirdParty/connect4/Solver.hpp>
#include <tuple>
#include <unordered_map>
#include <vector>
#include "BitBully.h"
#include "Board.h"
Include dependency graph for main.cpp:

Go to the source code of this file.

Typedefs

using Clock = std::chrono::high_resolution_clock
 Wall-clock used for the per-call timing measurements.

Functions

void writeToCSV (const std::vector< std::tuple< float, float > > &data, const std::string &filename)
 Persist per-position timing pairs to a CSV file.
std::unordered_map< std::string, std::string > parseArgs (const int argc, const char *const argv[])
 Parse --key value pairs from the program command line.
int main (const int argc, const char *const argv[])
 Entry point of the benchmark binary.

Detailed Description

Benchmark driver comparing BitBully against Pascal Pons' Connect-4 solver.

Generates a stream of random positions, asks both solvers to evaluate them with full perfect-play depth and compares the resulting scores. Per-call solve times are dumped to a CSV for offline analysis.

Command-line flags:

  • --nply N : number of stones in each generated position (default 8)
  • --nrepeats N : number of positions to evaluate (default 1000)
  • --filename PATH : output CSV file
  • --reset_tt N : reset both transposition tables every N positions

Definition in file main.cpp.

Typedef Documentation

◆ Clock

using Clock = std::chrono::high_resolution_clock

Wall-clock used for the per-call timing measurements.

Resolves to std::chrono::steady_clock on Windows (because high_resolution_clock is not actually high-resolution there) and to std::chrono::high_resolution_clock everywhere else.

Definition at line 42 of file main.cpp.

Function Documentation

◆ main()

int main ( const int argc,
const char *const argv[] )

Entry point of the benchmark binary.

Parameters
argcNumber of CLI arguments (as forwarded by the OS).
argvCLI arguments.
Returns
0 on success, EXIT_FAILURE if the two solvers disagree on any position or on argument-parsing errors.
Examples
quick_solve.cpp, score_all_moves.cpp, and with_opening_book.cpp.

Definition at line 108 of file main.cpp.

Here is the call graph for this function:

◆ parseArgs()

std::unordered_map< std::string, std::string > parseArgs ( const int argc,
const char *const argv[] )

Parse --key value pairs from the program command line.

Exits with EXIT_FAILURE if a key is missing its value.

Parameters
argcNumber of CLI tokens (as received by main).
argvCLI tokens.
Returns
Map from each --key token to its associated value.

Definition at line 84 of file main.cpp.

Here is the caller graph for this function:

◆ writeToCSV()

void writeToCSV ( const std::vector< std::tuple< float, float > > & data,
const std::string & filename )

Persist per-position timing pairs to a CSV file.

The file is written with header Bitbully,Pons-C4 and one row per (BitBully, Pons-C4) timing tuple, with five-digit fixed precision.

Parameters
dataPairs of (time_bitbully, time_pons_c4) in seconds.
filenameDestination CSV path.

Definition at line 54 of file main.cpp.

Here is the caller graph for this function: