/openai-gym-neat-games-ai

⚡Different Neural Networks Trained using the NEAT Algorithm to play 4 games provided by OpenAI Gym

Primary LanguagePython

openai-gym-neat-games-ai

Main Project Image (2)

project-description (15)

This is a Python Project Repository in which we use Neuro Evolution of Augmented Topologies (NEAT) Algorithm to train and test diffrent neural networks to play 4 games provided by OpenAI Gym. These four games are Bipedal Walker-v3, Cart Pole-v1, Mountain Car-v0, & Lunar Lander-v2 as seen in the preview image above. In this repository, each game has a script for training the neural network, a script for testing the neural network on the game, & a NEAT Configuration File located in the TrainingScripts, TestingScripts, & ConfigFiles respectively. After a model is trained for a game, The Neural Network with the best Fitness is stored as pickle file in the Winners folder. This repository already comes with trained models for each of the games, so feel free to test the models in the games using the testing scripts!

technologies-used (15)

Python OpenAI Gym NEAT Python NumPy Figma

how-to-use-project (10)

Install the following Python libraries in your Virtual Environment using PIP.

Note: The library names are CASE-SENSITIVE for PIP installations below. Make sure your type them correctly.

Install NEAT for Python

pip install neat-python

Install OpenAI Gym for Python

pip install gym

Install Numpy for Python

pip install numpy

Download a copy of this repository onto your local machine and extract it into a suitable folder.

  • Open an IDE (VSCode Recommended) in the Root Directory of the Project. Make sure you follow this step for the scripts to work.
  • Create a Virtual Environment in that folder.
  • Install all the required Python libraries mentioned above.
  • The scripts to train models are all located in the TrainingScripts folder in the Root Directory. Similarly, the scripts to test models are located in the TestingScripts folder. Additionally, all the NEAT Config Files are located in the ConfigFiles folder.
  • To test a pre-existing model, open the testing script of the game you want to test and run the code by clicking on the Code Runner button or open the built-in terminal in VSCode/IDE and run the command shown below. The example below is to run and test the model for the Bipedal Walker game.
python TestingScripts/TestBidepalWalker.py
  • To train your own model, firstly, delete the pickle file of the corresponding game that you want to train from the Winners folder. Open the training script of the game you want to train and run the code by clicking on the Code Runner button or open the built-in terminal in VSCode/IDE and run the command shown below. The example below is to train the model for the Bipedal Walker game.
python TrainingScripts/BidepalWalker.py
  • Once the training process is done, follow Step 5 to test the model.
  • Enjoy using this project!