DeepGeneticSnake
Snake game implementation with an AI that uses neural networks and a genetic algorithm, in Processing/Java.
Install / Use
/learn @CamGomezDev/DeepGeneticSnakeREADME
AI for Snake with a Genetic Algorithm and Neural Networks
This repository accompanies this video: https://www.youtube.com/watch?v=k2JqH5j2VYo.
The Java framework used is Processing and the main file is DeepGeneticSnake.pde. I've made comments to the code (in spanish) as well as I could.

To execute it's necessary to have Processing installed. After this, the repository must be just downloaded or cloned, opened from Processing and then run. The keys to control the simulation then show up. The classes NeuralNet.pde and Matrix.pde were gotten from the code that accompanies this Code Bullet video https://www.youtube.com/watch?v=3bhP7zulFfY.
The AI consists in a genetic algorithm that, in each generation, create 2000 snakes and then chooses the best ones and combines its brain for the next generation. The best ones, in this case, are defined as the ones that got a highest fitness, where the fitness function is defined in Snake.pde in the function died(). The brains are the neural networks, and to combine them means to create a new one with some nodes copied from one some others from other, mutating some of them to generate variety.
If something is not understood you can let me know in the Issues.
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
