alphazero.jl

A generic, simple and fast implementation of Deepmind's AlphaZero algorithm.

https://github.com/jonathan-laurent/alphazero.jl

Science Score: 41.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 11 committers (9.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.9%) to scientific vocabulary

Keywords

alphazero deep-learning julia machine-learning

Keywords from Contributors

graphics numerical sciml
Last synced: 10 months ago · JSON representation ·

Repository

A generic, simple and fast implementation of Deepmind's AlphaZero algorithm.

Basic Info
Statistics
  • Stars: 1,294
  • Watchers: 26
  • Forks: 142
  • Open Issues: 58
  • Releases: 6
Topics
alphazero deep-learning julia machine-learning
Created almost 7 years ago · Last pushed 11 months ago
Metadata Files
Readme Changelog License Citation

README.md


This package provides a generic, simple and fast implementation of Deepmind's AlphaZero algorithm:

  • The core algorithm is only 2,000 lines of pure, hackable Julia code.
  • Generic interfaces make it easy to add support for new games or new learning frameworks.
  • Being between one and two orders of magnitude faster than competing alternatives written in pure Python, this implementation can solve nontrivial games on a standard desktop computer with a GPU.
  • The same agent can be trained on a cluster of machines as easily as on a single computer and without modifying a single line of code.

Why should I care about AlphaZero?

Beyond its much publicized success in attaining superhuman level at games such as Chess and Go, DeepMind's AlphaZero algorithm illustrates a more general methodology of combining learning and search to explore large combinatorial spaces effectively. We believe that this methodology can have exciting applications in many different research areas.

Why should I care about this implementation?

Because AlphaZero is resource-hungry, successful open-source implementations (such as Leela Zero) are written in low-level languages (such as C++) and optimized for highly distributed computing environments. This makes them hardly accessible for students, researchers and hackers.

The motivation for this project is to provide an implementation of AlphaZero that is simple enough to be widely accessible, while also being sufficiently powerful and fast to enable meaningful experiments on limited computing resources. We found the Julia language to be instrumental in achieving this goal.

Training a Connect Four Agent

To download AlphaZero.jl and start training a Connect Four agent, just run:

sh export GKSwstype=100 # To avoid an occasional GR bug git clone https://github.com/jonathan-laurent/AlphaZero.jl.git cd AlphaZero.jl julia --project -e 'import Pkg; Pkg.instantiate()' julia --project -e 'using AlphaZero; Scripts.train("connect-four")'


Each training iteration takes about one hour on a desktop computer with an Intel Core i5 9600K processor and an 8GB Nvidia RTX 2070 GPU. We plot below the evolution of the win rate of our AlphaZero agent against two baselines (a vanilla MCTS baseline and a minmax agent that plans at depth 5 using a handcrafted heuristic):



Note that the AlphaZero agent is not exposed to the baselines during training and learns purely from self-play, without any form of supervision or prior knowledge.

We also evaluate the performances of the neural network alone against the same baselines. Instead of plugging it into MCTS, we play the action that is assigned the highest prior probability at each state:



Unsurprisingly, the network alone is initially unable to win a single game. However, it ends up significantly stronger than the minmax baseline despite not being able to perform any search.

For more information on training a Connect Four agent using AlphaZero.jl, see our full tutorial.

Resources

Contributors

  • Jonathan Laurent: main developer
  • Pavel Dimens: logo design
  • Marek Kaluba: hyperparameters tuning for the grid-world example
  • Michał Łukomski: Mancala example, OpenSpiel wrapper
  • Johannes Fischer: documentation improvements

Contributions to AlphaZero.jl are most welcome. Many contribution ideas are available in our contribution guide. Please do not hesitate to open a Github issue to share any idea, feedback or suggestion.

Supporting and Citing

If you want to support this project and help it gain visibility, please consider starring the repository. Doing well on such metrics may also help us secure academic funding in the future. Also, if you use this software as part of your research, we would appreciate that you include the following citation in your paper.

Related Julia Projects

  • AlphaGPU.jl: an AlphaZero implementation inspired from the "Scaling Scaling Laws with Board Games" paper, where almost everything happens on GPU (including the core MCTS logic). This implementation trades off some genericity and flexibility in exchange for unbeatable performances when used with small neural networks and environments that support batch-simulation on GPU.
  • ReinforcementLearning.jl: a reinforcement learning framework that leverages Julia's multiple dispatch to offer highly composable environments, algorithms and components. Future releases of AlphaZero.jl may build on this framework, as it gains better support for multithreaded and distributed RL.
  • POMDPs.jl: a fast, elegant and well-designed framework for working with partially observable Markov decisions processes.

Acknowledgements

This material is based upon work supported by the United States Air Force and DARPA under Contract No. FA9550-16-1-0288 and FA8750-18-C-0092. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the United States Air Force and DARPA.

Owner

  • Name: Jonathan Laurent
  • Login: jonathan-laurent
  • Kind: user
  • Location: Pittsburgh
  • Company: Carnegie Mellon University

Citation (CITATION.bib)

@misc{Laurent2020AlphaZero,
  author = {Jonathan Laurent},
  title = {AlphaZero.jl: A generic, simple and fast AlphaZero implementation},
  year = {2021},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/jonathan-laurent/AlphaZero.jl}},
}

GitHub Events

Total
  • Issues event: 5
  • Watch event: 57
  • Issue comment event: 20
  • Push event: 4
  • Pull request event: 5
  • Fork event: 10
  • Create event: 5
Last Year
  • Issues event: 5
  • Watch event: 57
  • Issue comment event: 20
  • Push event: 4
  • Pull request event: 5
  • Fork event: 10
  • Create event: 5

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 645
  • Total Committers: 11
  • Avg Commits per committer: 58.636
  • Development Distribution Score (DDS): 0.043
Past Year
  • Commits: 4
  • Committers: 1
  • Avg Commits per committer: 4.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Jonathan Laurent j****t@c****u 617
CompatHelper Julia c****y@j****g 8
johannes-fischer 4****r 6
Michał Łukomski m****1@g****m 3
gwario m****r@g****m 3
Carlo Lucibello c****o@g****m 2
Andreas Spanopoulos a****s@g****m 2
Yutai Zhou y****h@g****m 1
Scott P. Jones S****s 1
Matt Bauman m****n@j****m 1
Lilith Orion Hafner 6****r 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 86
  • Total pull requests: 45
  • Average time to close issues: 2 months
  • Average time to close pull requests: about 2 months
  • Total issue authors: 32
  • Total pull request authors: 14
  • Average comments per issue: 3.59
  • Average comments per pull request: 0.87
  • Merged pull requests: 16
  • Bot issues: 0
  • Bot pull requests: 18
Past Year
  • Issues: 4
  • Pull requests: 4
  • Average time to close issues: 2 months
  • Average time to close pull requests: N/A
  • Issue authors: 4
  • Pull request authors: 1
  • Average comments per issue: 5.25
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 4
Top Authors
Issue Authors
  • StepHaze (23)
  • smart-fr (14)
  • Snimm (6)
  • gwario (4)
  • DmitriMedved (4)
  • pepa65 (3)
  • jonathan-laurent (3)
  • bwanab (3)
  • casper2002casper (2)
  • A-Cepheus (1)
  • nateybear (1)
  • 70Gage70 (1)
  • lambe (1)
  • bochen0909 (1)
  • JuliaTagBot (1)
Pull Request Authors
  • github-actions[bot] (22)
  • AndrewSpano (5)
  • casper2002casper (4)
  • gwario (3)
  • Whojo (3)
  • ScottPJones (2)
  • CarloLucibello (2)
  • Snimm (2)
  • johannes-fischer (2)
  • umbriquse (1)
  • bhalonen (1)
  • SyxP (1)
  • LilithHafner (1)
Top Labels
Issue Labels
enhancement (2)
Pull Request Labels

Dependencies

.github/workflows/TagBot.yml actions
  • JuliaRegistries/TagBot v1 composite
.github/workflows/CompatHelper.yml actions