slcz / gomoku-deep-learning

gomoku AI with deep learning and monte carlo tree search

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gomoku game with DQN and Monte Carlo Tree Search (MCTS)

Gomoku game written in tensorflow, trained with Cnn and using MCTS rollout to play. MCTS part needs more debugging and is better turned off. You can get a reasonably strong AI player (<15x15 board) with just deep neural netowrk prediction.

Requirement

The model is trained on single Nvidia 1080 GTX, with tensorflow 1.0 and python 3. Pyhton packages required: - numpy - flask - tensorflow

Basic Usage:

  • Play with pretrained model, should be reasonable at e.g. 11x11, 15x15 board size. This only uses Dqn network, no searching involved!
python gomoku.py --agent1 web --agent2 dqntest --agent2_model G20 --web --boardsize 11 # Browser points to http://127.0.0.1:5000 to play a game with AI.
  • Training models with default parameters. The script repeatedly searches for the latest (greatest?) model under saved_models and randomly selects an opponent model for training.
    $ ./train.py
  • AI using MCTS against human opponent using a pretrained model.
    $ ./gomoku.py --agent1 montecarlo --agent2 web --agent1_model G79 --boardsize 15 --web

The example uses pretrained model G79. Use http://:5000 to connect to the game engine.

  • Play using pretrained model without MCTS search.
    $ ./gomoku.py --agent1 web --agent2 dqntest --agent2_model G79 --boardsize 15 --web
  • Two AIs against each other
    $ ./gomoku.py --agent1 montecarlo --agent2 montecarlo --agent1_model G78 --agent2_model G79 --boardsize 15 --web
  • Two AI players and AI visualization
    $ ./gomoku.py --agent1 montecarlo --agent2 montecarlo --agent1_model G78 --agent2_model G79 --boardsize 15 --web --display_AI

Demo

About

gomoku AI with deep learning and monte carlo tree search

License:GNU General Public License v3.0


Languages

Language:Python 86.7%Language:JavaScript 12.8%Language:HTML 0.5%