#427 · Primary category: Education & Research

snake

ai algorithm artificial-intelligence deep-reinforcement-learning game graph-theory python reinforcement-learning snake snake-ai

Playing the game of snake with AI.

Project last updated:04/19/26

GitHub Stars

1.8K

Forks

579

Contributors

4

License

MIT

Why we included this project

Here is a compact Python project that makes it easy to see two very different ways of playing snake side by side. One agent treats the game grid as a graph and plans its moves using shortest paths and Hamiltonian cycles, adding detours when it needs to avoid cornering itself. The other is a Double DQN agent trained in PyTorch, which learns purely from rewards with no hand-coded strategy. The two implementations are cleanly separated in the codebase, so you can study either approach on its own. Because the environment is a small 6x6 grid and a pretrained model is included, it also works well as a hands-on introduction to Q-learning and DQN training loops.

Articles for this project

No articles for this project yet.

To suggest a topic or contribute an article, contact us.

Related projects in this category