MIT License

项目介绍

suragnair/alpha-zero-general 是一个托管在 GitHub 上的开源项目,主要使用 Jupyter Notebook 编写,采用 MIT License 许可证,目前获得 4.5k 个 Star、1.2k 次 Fork。

仓库全名
suragnair/alpha-zero-general
开源许可证
MIT License
Star 数
4.5k
Fork 数
1.2k
未关闭 Issue
76

README 摘要

Alpha Zero General (any game, any framework!) A simplified, highly flexible, commented and (hopefully) easy to understand implementation of self-play based reinforcement learning based on the AlphaGo Zero paper (Silver et al). It is designed to be easy to adopt for any two-player turn-based adversarial game and any deep learning framework of your choice. A sample implementation has been provided for the game of…

完整内容见 GitHub 原始 README 或本页 。

常见问题

alpha-zero-general 用什么语言开发?

主要使用 Jupyter Notebook 编写,采用 MIT License 许可证,目前有 4.5k 个 Star。

alpha-zero-general 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 alpha-zero-general 的源码?

可以直接克隆仓库:git clone https://github.com/suragnair/alpha-zero-general.git,默认分支为 master;安装与运行步骤见仓库 README。

alpha-zero-general 最近还在维护吗?

仓库最近一次更新为 2025年1月2日,当前有 76 个未关闭 Issue;Star 数为 4.5k,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

A clean implementation based on AlphaZero for any game in any framework + tutorial + Othello/Gobang/TicTacToe/Connect4 and more

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

Jupyter Notebook
Python
Shell

README

Alpha Zero General (any game, any framework!)

A simplified, highly flexible, commented and (hopefully) easy to understand implementation of self-play based reinforcement learning based on the AlphaGo Zero paper (Silver et al). It is designed to be easy to adopt for any two-player turn-based adversarial game and any deep learning framework of your choice. A sample implementation has been provided for the game of Othello in PyTorch and Keras. An accompanying tutorial can be found here. We also have implementations for many other games like GoBang and TicTacToe.

To use a game of your choice, subclass the classes in Game.py and NeuralNet.py and implement their functions. Example implementations for Othello can be found in othello/OthelloGame.py and othello/{pytorch,keras}/NNet.py.

Coach.py contains the core training loop and MCTS.py performs the Monte Carlo Tree Search. The parameters for the self-play can be specified in main.py. Additional neural network parameters are in othello/{pytorch,keras}/NNet.py (cuda flag, batch size, epochs, learning rate etc.).

To start training a model for Othello:

python main.py

Choose your framework and game in main.py.

Docker Installation

For easy environment setup, we can use nvidia-docker. Once you have nvidia-docker set up, we can then simply run:

./setup_env.sh

to set up a (default: pyTorch) Jupyter docker container. We can now open a new terminal and enter:

docker exec -ti pytorch_notebook python main.py

Experiments

We trained a PyTorch model for 6x6 Othello (~80 iterations, 100 episodes per iteration and 25 MCTS simulations per turn). This took about 3 days on an NVIDIA Tesla K80. The pretrained model (PyTorch) can be found in pretrained_models/othello/pytorch/. You can play a game against it using pit.py. Below is the performance of the model against a random and a greedy baseline with the number of iterations. alt tag

A concise description of our algorithm can be found here.

Citation

If you found this work useful, feel free to cite it as

@misc{thakoor2016learning,
  title={Learning to play othello without human knowledge},
  author={Thakoor, Shantanu and Nair, Surag and Jhunjhunwala, Megha},
  year={2016},
  publisher={Stanford University, Final Project Report}
}

Contributing

While the current code is fairly functional, we could benefit from the following contributions:

  • Game logic files for more games that follow the specifications in Game.py, along with their neural networks
  • Neural networks in other frameworks
  • Pre-trained models for different game configurations
  • An asynchronous version of the code- parallel processes for self-play, neural net training and model comparison.
  • Asynchronous MCTS as described in the paper

Some extensions have been implented here.

Contributors and Credits

Note: Chainer and TensorFlow v1 versions have been removed but can be found prior to commit 2ad461c.

评论

暂无评论