/lets-do-ttt-with-mcts

Tic Tac Toe with MCTS

Primary LanguageJupyter Notebook

Tic Tac Toe with MCTS

Let's play Tic Tac Toe game with MCTS

Install

Requirements

You need a networkx python library.

  • Install the latest version of NetworkX

    $ pip install networkx
  • Install with all optional dependencies

    $ pip install networkx[all]
  • If you are a Mac OS user, you can use homebrew to install graphviz first

    $ brew install graphviz

    Check where is the output directory

    $ brew info graphviz

    In my case, it was /opt/homebrew/Cellar/graphviz/2.50.0.

    Then run

    $ export GRAPHVIZ_DIR="/opt/homebrew/Cellar/graphviz/2.50.0"
    $ pip install pygraphviz --global-option=build_ext --global-option="-I$GRAPHVIZ_DIR/include" --global-option="-L$GRAPHVIZ_DIR/lib"

How to use

  1. MCTS with rollout

    $ cd src/mcts_rollout
    $ python tic_tac_toe.py
  2. MCTS without rollout

    $ cd src/mcts_no_rollout
    $ python tic_tac_toe.py

Example

You can show Monte Carlo Tree graph.

D : Depth
V : Visits
R : Reward
Q : R / V
P : Player

Reference