An implementation of a simple game provided to check extendability of the framework. Main difference of this game comparing to Othello is that it allows draws, i.e. the cases when nobody won after the game ended. To support such outcomes Arena.py
and Coach.py
classes were modified. Neural network architecture was copy-pasted from the game of Othello, so possibly it can be simplified.
To train a model for TicTacToe, change the imports in main.py
to:
from Coach import Coach
from tictactoe.TicTacToeGame import TicTacToeGame
from tictactoe.keras.NNet import NNetWrapper as nn
from utils import *
and the first line of __main__
to
g = TicTacToeGame()
Make similar changes to pit.py
.
To start training a model for TicTacToe:
python main.py
To start a tournament of 100 episodes with the model-based player against a random player:
python pit.py
You can play againt the model by switching to HumanPlayer in pit.py
I trained a Keras model for 3x3 TicTacToe (3 iterations, 25 episodes, 10 epochs per iteration and 25 MCTS simulations per turn). This took about 30 minutes on an i5-4570 without CUDA. The pretrained model (Keras) can be found in pretrained_models/tictactoe/keras/
. You can play a game against it using pit.py
.
The implementation is based on the game of Othello (https://github.com/suragnair/alpha-zero-general/tree/master/othello).
- February 8, 2018 - Advanced Spark/Tensorflow Meetup at Thumbtack: Youtube / Slides
- March 6, 2018 - Advanced Spark/Tensorflow Meetup at Strata San Jose: Youtube / Slides