42kangaroo / Muele_AI

This is a school project that aims to train an artificial intelligence to play mill

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AlphaZero for Mill

This is a school project that aims to learn the game of Mill, also known as Nine Mens Morris, with the AlphaZero algorithm. It has been parallelized with multiprocessing and uses keras and TensorFlow for the Neural Networks.

The GUI

Table of Contents

How to install

To use this project, first clone the repo on your device using the command below:

git clone https://github.com/42kangaroo/Muele_AI.git

Then, change to the directory and install the dependencies:

cd Muele_AI
pip install -r requirements.txt

Usage

Training

Define your own Network in Network.py and change the hyperparameters in configs.py. Use a computer with a GPU for training, or it will need a very long time. To install TensorFlow for the GPU follow these Tutorials for Windows and Linux. Then, start the program with

py main.py

The program will return with an error if the files interrupt_array.npy or interrupt_vars.obj persist in the main directory. Delete these files in this case.

If you need to stop the program in the middle of training, press ctrl+C and wait a little. The files interrupt_array.npy and interrupt_vars.obj will appear. If they don't, copy them from the directory you configured in configs.py. The program will then continue at the same point you interrupted it.

The trained net will appear in the configured directory with the name whole_net.

Play

When you open the file Graphics.py you will find this line at the end of the file:

MCGraphics = ModeratedGraphics("run5/models/whole_net", 12, 1.05)
MCGraphics.playLoop()

Choose the directory of your preferred Network and change it in the file. You can also make it better and slower or faster and worse by changing the number of simulations.

You can then start the program with

py Graphics.py

Technologies

I used these libraries for my project.

Project Status

I'm almost finished with this project, and I only need to train it one last time now. I don't have time to train it with a Graph Neural Network.

Documentation

You can read the documentation and the project paper by following the links (both in german).

Contributors

Thanks to @halloalexkern and Oliver Peyron for letting me use there computer for training. I also want to thank @rempfler for the tips he gave me for the Networks.

License

This project is licensed under the GNU General Public License v3.0

Other Methods

I also tried to learn the game of Mill with MCTS and Reinforcement learning. See MCTS and Reinforce branch.

About

This is a school project that aims to train an artificial intelligence to play mill

License:GNU General Public License v3.0


Languages

Language:Python 100.0%