devesh-002 / Beginner-AI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

README

Introduction:-

This is a implementation for Connect4 AI and the readme aims on explaining the file structure and dependencies only, regarding more intrinsic details on why stuff works check out the report of the Project. The dependencies here are tried to be kept as close to the original alpha-zero as the original one also used Tensorflow and keras.

Dependencies:-

  1. Pygame version 2.0.1
  2. Tensorflow 2.6.0
  3. Keras 2.1.6
  4. Numpy
  5. Python 3

Run the Programme:-

To run it simply cd into the Alpha_zero directory or the classical_eval directory and run

python3 visualise.py

File Structure:-

code folder contains some of my implementations and src is the main game playing folder. This has 2 parts one being the Classical Evaluation which uses minimax and other being the Neural-Network part which has the projects, both having a seperate visualise.py file. To run this on your local machine run the visualise.py file in your computer. Make sure you are in the same directory as your file is in else there can be a few path errors. There is no need for any datasets as the model produces datasets from its own by playing with itself.

  1. To train you own model run the train.py file and to custom change anything along to your needs, change the variables in initialiser.py.
  2. C4.py contains the entire class of Connect i.e. the implementation of the entire game, it uses lists to make an empty board and then works further from there.
  3. Neural_Network.py contains a custom made model according to the description of Google Deepbrain, to learn more about it see the Report.
  4. self_train.py generates games so that the neural network can learn from itself.
  5. mct.py and node_class.py are files for the MCT structure which is different from a generic MCT file and is made according to the needs of alpha zero and its evaluations.
  6. minimax.py contains the implementation of the minimax algorithm and evaluation.py provides for the evaluation function of it.
  7. Note that Depth>4 can be implemented but is not supported right now because it was taking a lot of time. models/ folder contains few trained model in .h5 format and can be downloaded directly.

Models folder:- The levels are clearly specified in the model and they all vary over the amount of training provided with Level 4 trained over 5000 epochs, Level 3 over 3000 epochs, Level 2 over 500 epochs and Level 1 over just 3 to demonstrate it's learning. Similarly in minimax the depth signifies the level of the game.

A sample game played with the AI is :-

Alt Text

About

License:MIT License


Languages

Language:Python 82.9%Language:C++ 17.1%