Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Snake GA - Genetic algorithm that solves the Snake game. GA was implemented by PyGAD library available for Python, neural networks was created in Keras and game was created in Pygame.

License

petomuro/Snake-GA

Repository files navigation

Snake-GA

Snake GA - Genetic algorithm that solves the Snake game. GA was implemented by PyGAD library available for Python, neural networks was created in Keras and game was created in Pygame.

You have to installed Python 3.7.9 and other requirements which are necessary for run the program (requirements.txt).

Example

Train neural network

If you want to train neural network, you need to:

  1. change OPTIMIZATION = True
  2. run main.py

Example

Test neural network

When the training of neural network is complete, a file will be created in the weights folder.

If you want to test trained neural network you need to:

  1. change OPTIMIZATION = False
  2. change in neural_network.py --> self.network.load_weights('weights/model_name.h5') --> e.g. self.network.load_weights('weights/model20210526044312.h5')
  3. run main.py

Create graph

When the training is complete, a file will be created in the results folder.

If you want to create graph you need to:

  1. change in helper.py --> with open('results/results_name.csv') as results_file: --> e.g. with open('results/results20210520223339.csv') as results_file:
  2. run helper.py

About

Snake GA - Genetic algorithm that solves the Snake game. GA was implemented by PyGAD library available for Python, neural networks was created in Keras and game was created in Pygame.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages