Back
Close

MCTS Tic Tac Toe Playground

Goal

The goal of this playground is show how the Monte Carlo Tree Search (MCTS) algorithm works, applied to a simple two player game. It is oriented towards people who are acquainted with the theory of MCTS but experience difficulties implementing it. Below is a basic and (hopefully) easy to follow implementation demonstrating the game play of Tic Tac Toe. For ease of reading the four main steps of the algorithm are indicated as comments in the code.

Notice

The code below does not use best practices in programming or MCTS implementation. This playground is to be perceived as a proof of concept example of how the algorithm works. If you want you can contribute by making it more accessible by restructuring it or by translating the code to other languages.

Code

Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants