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
IntuitionDataGenerator Class Reference

This class is used to generate the data required for the intuition learning process. More...

#include <intuition_data_generator.hpp>

Inheritance diagram for IntuitionDataGenerator:
AlphaBeta ChineseCheckers

Public Member Functions

std::pair< std::vector< bitBoards_t >, std::vector< double > > evalAllMoves (int depth)
 
template<typename T >
void saveVectorToFile (const std::vector< T > &input, const std::string &outputFileName)
 
void saveVectorOfBitBoardsToFiles (const std::vector< bitBoards_t > &input, const std::string &outputFileNameW, const std::string &outputFileNameB)
 
void fillTransTable ()
 
- Public Member Functions inherited from AlphaBeta
 AlphaBeta ()
 
 AlphaBeta (const std::vector< double > &player_to_win_value_, const std::vector< double > &player_to_lose_value_)
 
ListOfPositionType getMove (const int &depth, const double &alpha, const double &beta)
 
uint_fast64_t getMove64 (const int &depth)
 
void availableMoves (std::set< uint_fast64_t, decltype(comp_move_)> &result)
 
void tensorflowSortMoves (std::set< uint_fast64_t, decltype(comp_move_)> &possible_moves)
 
const double AlphaBetaEval (const int &depth, double alpha, double beta, const bool &maximizingPlayer, const bool &keepMove, uint_fast64_t hash)
 
bool isHuman ()
 
void loadOpenings ()
 
Player getMaximizingPlayer () const
 
std::vector< double > getPlayerToLoseValue ()
 
std::vector< double > getPlayerToWinValue ()
 
void setPlayerToLoseValue (const std::vector< double > &player_to_lose_value_)
 
void setPlayerToWinValue (const std::vector< double > &player_to_win_value_)
 
- Public Member Functions inherited from ChineseCheckers
 ChineseCheckers ()
 
void newGame ()
 
bool move (const Player &player, const ListOfPositionType &list_moves)
 
Result stateOfGame ()
 
void moveWithoutVerification (const uint_fast64_t &move)
 
Player getWhoIsToPlay () const
 
uint_fast64_t getBitBoardWhite () const
 
uint_fast64_t getBitBoardBlack () const
 
void printGrid () const
 
void printWhoIsToPlay () const
 

Protected Attributes

boost::unordered_map< bitBoards_t, uint_fast64_t, bitBoardsHasher, bitBoardsEqual > transposition_table_permanent_
 
- Protected Attributes inherited from AlphaBeta
std::vector< double > player_to_win_value_
 
std::vector< double > player_to_lose_value_
 
Player maximizing_player_
 
uint_fast64_t best_move_
 
boost::unordered_map< uint_fast64_t, std::pair< double, int > > transposition_table_
 
boost::unordered_map< uint_fast64_t, std::pair< double, int > >::iterator it_transposition_table_
 
std::array< boost::unordered_map< bitBoards_t, uint_fast64_t, bitBoardsHasher, bitBoardsEqual >, 2 > opening_
 
cppflow::model * model = new cppflow::model("model")
 
std::unordered_map< uint_fast64_t, double > result_tensorFlow_
 
double heuristic_value_
 
int fullDepth_
 
std::array< bool, 2 > won_ = {false, false}
 
- Protected Attributes inherited from ChineseCheckers
const uint_fast64_t un_64_ = static_cast<uint_fast64_t>(1)
 
Player who_is_to_play_ = 0
 
bitBoards_t bit_boards_
 
uint_fast64_t zobrist_hash_
 
std::array< boost::unordered_map< uint_fast64_t, uint_fast64_t >, 2 > zobrist_keys_
 
std::array< boost::unordered_map< uint_fast64_t, uint_fast64_t >, 2 > zobrist_keys_moves_
 
boost::unordered_map< uint64_t, int > number_of_times_seen_
 
std::vector< uint64_t > positions_seen_
 
const uint_fast64_t winning_positions_white_ = 0xF0E0C08000000000
 
const uint_fast64_t winning_positions_black_ = 0x000000000103070F
 
const boost::unordered_map< uint32_t, bool > illegal_positions_
 
const std::array< std::array< uint32_t, 8 >, 8 > cantor_pairing_
 
const std::vector< std::vector< int > > valid_lines
 
const std::vector< std::vector< int > > valid_lines_illegal
 
const std::array< std::pair< int, int >, 64 > uint64_to_pair_
 
const std::array< std::array< uint_fast64_t, 8 >, 8 > int_to_uint64_
 
const std::array< std::vector< uint_fast64_t >, 64 > direct_neighbours_
 
const std::array< std::vector< std::vector< std::pair< std::pair< uint_fast64_t, uint_fast64_t >, uint_fast64_t > > >, 64 > k_neighbours_
 

Additional Inherited Members

- Public Attributes inherited from AlphaBeta
std::function< bool(const uint_fast64_t &, const uint_fast64_t &)> comp_move_
 
std::function< bool(const uint_fast64_t &, const uint_fast64_t &)> comp_move_black_
 
std::function< bool(const uint_fast64_t &, const uint_fast64_t &)> comp_move_white_
 
- Protected Member Functions inherited from AlphaBeta
double heuristicValue ()
 
void updateHeuristicValue (const uint_fast64_t &move)
 
void updateHeuristicValueBack (const uint_fast64_t &move)
 
std::vector< uint8_t > bitBoardsAsVector (const bitBoards_t &bb)
 
ListOfPositionType retrieveMoves (const uint_fast64_t &move)
 
- Protected Member Functions inherited from ChineseCheckers
MoveType elementaryMove (const PositionType &original_position, const PositionType &arrival_position) const
 
bool isPositionIllegal () const
 
int cantorPairingFunction (const int &x, const int &y) const
 
boost::unordered_map< uint32_t, bool > loadIllegalPositions () const
 
void generateZobristKeys ()
 
void computeAndSetZobristHash ()
 

Detailed Description

This class is used to generate the data required for the intuition learning process.

Member Function Documentation

◆ evalAllMoves()

std::pair< std::vector< bitBoards_t >, std::vector< double > > IntuitionDataGenerator::evalAllMoves ( int  depth)

this function is used to eval all possible moves.

Parameters
depthThe depth used by the alpha beta algorithm.
Returns
The evaluation associated with each move and the grid obtained after each move.

◆ fillTransTable()

void IntuitionDataGenerator::fillTransTable ( )

Fill the transposition_table_ with the data we already calculated.

◆ saveVectorOfBitBoardsToFiles()

void IntuitionDataGenerator::saveVectorOfBitBoardsToFiles ( const std::vector< bitBoards_t > &  input,
const std::string &  outputFileNameW,
const std::string &  outputFileNameB 
)

Save a matrix to a file.

Parameters
inputThe matrix to save.
outputFileNameThe name of the file we need to save the data to.

◆ saveVectorToFile()

template<typename T >
void IntuitionDataGenerator::saveVectorToFile ( const std::vector< T > &  input,
const std::string &  outputFileName 
)

Save a vector to a file.

Template Parameters
T
Parameters
inputThe vector to save.
outputFileNameThe name of the file we need to save the data to.

Member Data Documentation

◆ transposition_table_permanent_

boost::unordered_map<bitBoards_t, uint_fast64_t, bitBoardsHasher, bitBoardsEqual> IntuitionDataGenerator::transposition_table_permanent_
protected

The documentation for this class was generated from the following files: