/monte-carlo-tictactoe

An implementation of an agent that uses Monte Carlo tree search to play tic-tac-toe

Primary LanguagePython

Monte Carlo Tic-Tac-Toe

Here is an implementation of an AI agent, TicTacPro which plays tic-tac-toe using Monte Carlo tree search. The underlying game environment is provided by gym-tictactoe, and the agents are modeled after their example code.

Usage

# install requirements
pip install -r requirements.txt

# simulate some games
python run.py

Code Layout

  • The Monte Carlo Tree Search is implemented inside agents.py, for the AI agent TicTacPro.

  • Like the other, simpler agents, TicTacPro has an act method which takes the current state & environment, and returns the move it wants to make. Each time act is called, the agent builds up a new tree.

  • In run.py, this agent can be made to play against its historic rival, TicTacJoe.