Skip to content

Thb1t/AI_snake_genetic_version

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ Snake AI Using NEAT (NeuroEvolution)

This project features an AI that learns to play Snake autonomously using the NEAT (NeuroEvolution of Augmenting Topologies) algorithm. No hardcoded strategies โ€” the agent improves over generations through genetic mutations and natural selection. ๐Ÿงฌ๐Ÿค–

๐Ÿง  What It Does

๐Ÿ•น๏ธ The AI controls a snake in a classic grid-based Snake game.

๐Ÿงฌ It evolves over time using NEAT: networks mutate, reproduce, and get selected based on performance (fitness).

๐Ÿ‘๏ธ Visual interface shows the best snake live as it learns.

๐Ÿš€ Features

๐Ÿ”„ No supervised learning โ€“ only evolution by fitness

๐Ÿง  Networks evolve topologies and weights

๐Ÿ“Š Real-time simulation with visualization

๐Ÿ† Tracks best fitness, average scores, and generation progress

Here is an image of what it looks like :

Image_snake

๐Ÿ“ฆ Dependencies

  • Python 3.x ๐Ÿ
  • neat-python
  • pygame for visualization ๐ŸŽฎ

๐Ÿ“ Notes

โณ Training takes time โ€“ early generations play poorly but evolve quickly. I train it approximately 15h and the best score is 13 apples. Here is the best neural network :

NN_snake

๐Ÿงช You can adjust mutation rates, population size, and other parameters in the NEAT config file.

About

AI to play snake with Neat & Pygame

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages