Giter Site home page Giter Site logo

patrikasvanagas / mcts-hex-cpp14 Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 1.02 MB

A Hex board game with a customizable Monte Carlo Tree Search (MCTS) agent with optional leaf parallelization in C++14. Includes a logging functionality for MCTS insights.

License: MIT License

C++ 98.97% CMake 0.46% Makefile 0.58%
cpp14 hex-game mcts mcts-agents mcts-algorithm mcts-implementations mcts-solver mcts-visualisation monte-carlo-tree-search leaf-parallelization

mcts-hex-cpp14's Introduction

Hex Board Game with Monte Carlo Tree Search Agent in C++14

This repository contains an implementation of the board game of Hex with an agent based on Monte Carlo Tree Search (MCTS) utilizing optional leaf parallelization in a console interface. The MCTS agent has configurable hyperparameters, and the size of the board is variable. Standard C++14 libraries are used.

img1

Features

The application includes several modes of gameplay:

  • Human vs Robot: A user competes against the AI.
  • Robot vs Robot: Two AI agents compete, allowing for evaluation and comparison of different hyperparameters.
  • Human vs Human: Two users compete, each taking turns on the same console.

For those interested in studying MCTS, the application provides optional logging functionality. When operated in single-threaded mode, the agent is capable of producing a detailed log, showing the decision-making process behind each move across MCTS iterations.

img2

Structure

  • Cell_state: An enum that symbolizes the state of a Hex game board cell - it could be vacant or claimed by a player (Blue or Red).
  • Board: represents the Hex game board, providing functionality for its initialization, move validation, game state representation, determining the game outcome using recursive depth-first search, and visualization.
  • Mcts_agent: Implements the MCTS algorithm simulating gameplay to select the most promising move, supporting optional thread-safe parallelization and detailed logging. The nested class Node symbolizes a game tree node.
  • Logger: A thread-safe singleton class for logging operations and state changes within the MCTS algorithm. It is used as a member class of Mcts_agent.
  • Player: An abstract base class that outlines the necessary structure and methods for any player type in a game, with Human_player and Mcts_player as concrete subclasses representing a human player and a player that uses MCTS.
  • Game: Encapsulates a complete Hex game, handling the game loop, player turns, board management, and state transitions for two players.
  • console_interface: A suite of functions that provide an interactive console interface for users to set up and play different configurations of the Hex game, handle user input validation, manage game parameters, and display relevant game information.
  • main: invokes the run_console_interface function.

Refer to the corresponding header files for detailed documentation.

Building

The recommended method to build the project is via Visual Studio with the C++ Desktop Development environment installed. Once installed, follow these steps:

  1. Click the green 'Code' button at the top of this page.
  2. Select 'Open with Visual Studio'.
  3. In the Solution Explorer, select the CMakeLists.txt file and build the project (F5).

Additionally, a Makefile is available for use.

Contributions to this project are welcome. Happy coding!

mcts-hex-cpp14's People

Contributors

patrikasvanagas avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.