Counting 2,784 Big Data & Machine Learning Frameworks, Toolsets, and Examples...
Suggestion? Feedback? Tweet @stkim1

Last Commit
May. 10, 2018
Jul. 6, 2017


Monte Carlo Tree Search Based AI Connect 4 Bot

Getting Started

About the game

Connect 4 is a two-player game in which the players take turns dropping colored discs from the top into a seven-column, six-row vertically suspended grid. The pieces fall straight down, occupying the next available space within the column. The objective of the game is to be the first to form a horizontal, vertical, or diagonal line of four of one's own discs.

It must be noted that this is a solved game (the first player can always win with right moves), the purpose of this project is mianly to implement the algorithm and test its performance in a simple game. We encourage users to find those right moves!

The algorithm

Monte Carlo Tree Search is a recently proposed search method that combines the precision of tree search with the generality of random sampling. It does not depend on heuristic function to evaluate the best next move to make, rather it just considers the game mechanics to play random rollouts and get an expected reward after a fixed number of iterations.

Here we attach some of papers as part of the literature revised for developing this project:

Running the game


The code was written in Python 2.7. In order to display the game's GUI, we used Tkinter module, which is the standard Python interface to the Tk GUI toolkit. Although you don't need to download Tkinter since it is an integral part of all Python distributions. In any case, you can find more details about Tkinter installation here.


git clone
cd Connect4

Have fun!


This project is licensed under the MIT License - see the file for details


  • Samuel Vidal, for suggesting this challenge.