ChineseCheckers
This project is a solver for two players' Chinese Checkers game using the Alpha Beta pruning algorithm. The program is written in C++ and uses a number of heuristics to improve the performance of the algorithm. Overall, the Chinese Checkers solver program has been built with performance in mind, and is designed to deliver fast and efficient game play. Whether you are playing against a bot or using the program as a library in your own project, you can be confident that the program will deliver high-performance results.
Loading...
Searching...
No Matches
tournament.cpp File Reference
#include "tournament.hpp"
#include <numbers>
#include <vector>
#include <random>
#include <chrono>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <fstream>
#include <thread>
#include <boost/python.hpp>
#include "Types.hpp"
#include "AlphaBeta.hpp"

Macros

#define P_MUTATION   0.1
 
#define SIGMA_MUTATION   0.05
 
#define SELECTION_RATIO   1
 
#define POP_SIZE   12
 
#define NUM_GENERATION   100
 
#define ROUND_LENGTH   3
 
#define MAX_NUM_MOVES   100
 
#define AB_DEPTH   1
 
#define MEAN_INIT   0
 
#define SIGMA_INIT   0.1
 
#define INIT_AT_RANDOM   0
 
#define N_THREADS   4
 

Functions

std::mt19937 generator (seed)
 
std::bernoulli_distribution b_distrib (P_MUTATION)
 
std::bernoulli_distribution unif_b_distrib (0.5)
 
std::normal_distribution< double > n_distrib (0, SIGMA_MUTATION)
 
std::normal_distribution< double > n_distrib_for_initialisation (MEAN_INIT, SIGMA_INIT)
 
std::uniform_int_distribution int_distrib (0, 100 *POP_SIZE)
 
int main ()
 
bool operator< (SolversIndividuals const &s1, SolversIndividuals const &s2)
 
void print_matrix (const std::vector< double > &matrix)
 
void write_scores (std::ofstream &file, std::vector< SolversIndividuals > &population, SolversIndividuals &best_to_write, const int &gen)
 
void evol (GamePlayer *gp, std::vector< SolversIndividuals > &population, SolversIndividuals *best_player, bool is_white_evolving)
 
void evol_thread (const std::vector< ThreadGamePlayer > &gps, std::vector< SolversIndividuals > &population, SolversIndividuals *best_player, bool is_white_evolving)
 

Variables

const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count()
 
auto mutates = std::bind(b_distrib, generator)
 
auto variation = std::bind(n_distrib, generator)
 
auto initiator_ = std::bind(n_distrib_for_initialisation,generator)
 
auto unif_bernouilli = std::bind(unif_b_distrib,generator)
 
auto unif_int = std::bind(int_distrib,generator)
 

Macro Definition Documentation

◆ AB_DEPTH

#define AB_DEPTH   1

◆ INIT_AT_RANDOM

#define INIT_AT_RANDOM   0

◆ MAX_NUM_MOVES

#define MAX_NUM_MOVES   100

◆ MEAN_INIT

#define MEAN_INIT   0

◆ N_THREADS

#define N_THREADS   4

◆ NUM_GENERATION

#define NUM_GENERATION   100

◆ P_MUTATION

#define P_MUTATION   0.1

◆ POP_SIZE

#define POP_SIZE   12

◆ ROUND_LENGTH

#define ROUND_LENGTH   3

◆ SELECTION_RATIO

#define SELECTION_RATIO   1

◆ SIGMA_INIT

#define SIGMA_INIT   0.1

◆ SIGMA_MUTATION

#define SIGMA_MUTATION   0.05

Function Documentation

◆ b_distrib()

std::bernoulli_distribution b_distrib ( P_MUTATION  )

◆ evol()

void evol ( GamePlayer gp,
std::vector< SolversIndividuals > &  population,
SolversIndividuals best_player,
bool  is_white_evolving 
)

◆ evol_thread()

void evol_thread ( const std::vector< ThreadGamePlayer > &  gps,
std::vector< SolversIndividuals > &  population,
SolversIndividuals best_player,
bool  is_white_evolving 
)

◆ generator()

std::mt19937 generator ( seed  )

◆ int_distrib()

std::uniform_int_distribution int_distrib ( ,
100 *  POP_SIZE 
)

◆ main()

int main ( )

◆ n_distrib()

std::normal_distribution< double > n_distrib ( ,
SIGMA_MUTATION   
)

◆ n_distrib_for_initialisation()

std::normal_distribution< double > n_distrib_for_initialisation ( MEAN_INIT  ,
SIGMA_INIT   
)

◆ operator<()

bool operator< ( SolversIndividuals const &  s1,
SolversIndividuals const &  s2 
)
See also
operator=

◆ print_matrix()

void print_matrix ( const std::vector< double > &  matrix)

◆ unif_b_distrib()

std::bernoulli_distribution unif_b_distrib ( 0.  5)

◆ write_scores()

void write_scores ( std::ofstream &  file,
std::vector< SolversIndividuals > &  population,
SolversIndividuals best_to_write,
const int &  gen 
)

Variable Documentation

◆ initiator_

auto initiator_ = std::bind(n_distrib_for_initialisation,generator)

◆ mutates

auto mutates = std::bind(b_distrib, generator)

◆ seed

const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count()

◆ unif_bernouilli

auto unif_bernouilli = std::bind(unif_b_distrib,generator)

◆ unif_int

auto unif_int = std::bind(int_distrib,generator)

◆ variation

auto variation = std::bind(n_distrib, generator)