Let's play Tic Tac Toe game with MCTS
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"
-
MCTS with rollout
$ cd src/mcts_rollout $ python tic_tac_toe.py
-
MCTS without rollout
$ cd src/mcts_no_rollout $ python tic_tac_toe.py
You can show Monte Carlo Tree graph. |
---|
D : Depth
V : Visits
R : Reward
Q : R / V
P : Player
-
Youtube : Monte Carlo Tree Search algorithm
-
Demo page : mcts-viz
-
Blog : Tic Tac Toe with MCTS