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.
|
#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) |
#define AB_DEPTH 1 |
#define INIT_AT_RANDOM 0 |
#define MAX_NUM_MOVES 100 |
#define MEAN_INIT 0 |
#define N_THREADS 4 |
#define NUM_GENERATION 100 |
#define P_MUTATION 0.1 |
#define POP_SIZE 12 |
#define ROUND_LENGTH 3 |
#define SELECTION_RATIO 1 |
#define SIGMA_INIT 0.1 |
#define SIGMA_MUTATION 0.05 |
std::bernoulli_distribution b_distrib | ( | P_MUTATION | ) |
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 | ||
) |
std::mt19937 generator | ( | seed | ) |
std::uniform_int_distribution int_distrib | ( | 0 | , |
100 * | POP_SIZE | ||
) |
int main | ( | ) |
std::normal_distribution< double > n_distrib | ( | 0 | , |
SIGMA_MUTATION | |||
) |
std::normal_distribution< double > n_distrib_for_initialisation | ( | MEAN_INIT | , |
SIGMA_INIT | |||
) |
bool operator< | ( | SolversIndividuals const & | s1, |
SolversIndividuals const & | s2 | ||
) |
void print_matrix | ( | const std::vector< double > & | matrix | ) |
std::bernoulli_distribution unif_b_distrib | ( | 0. | 5 | ) |
void write_scores | ( | std::ofstream & | file, |
std::vector< SolversIndividuals > & | population, | ||
SolversIndividuals & | best_to_write, | ||
const int & | gen | ||
) |
auto initiator_ = std::bind(n_distrib_for_initialisation,generator) |
const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count() |
auto unif_bernouilli = std::bind(unif_b_distrib,generator) |
auto unif_int = std::bind(int_distrib,generator) |