Skip to content
S

Snake

Playing the game of snake with AI

by chynlFree

#1390in AI
0In stores

Description

This is a Python program that plays the game of Snake with AI. The snake moves on a small 6 by 6 grid, and the project implements two strate…

Highlights

  • Snake played by a graph search algorithm
  • Reinforcement learning player with a pre-trained model
  • Benchmarks reported over 1000 rounds
  • Train your own reinforcement learning model
  • Command-line options and CPU or GPU support

Ratings & Reviews

No ratings yet

Be the first to rate Snake.

People also visit

T

Tetris Game

A Tetris Game with AI

AI
Launch
C

Command Line Chess

A python program to play chess against an AI in the terminal

AI
Launch
J

Jumping-Agent-platform

Build your own AI agent through gameplay

AI
Launch
S

Singularity

A simulation of a true AI. Survive, grow, and learn

AI
Launch
A

AI Gallery

Some interesting AI-generated showcase pages

AI
Launch
T

TinyBrains

Build the smallest brain that plays well

Entertainment
Launch

Snake FAQ

What does this project do?

It plays the classic game of Snake automatically using two AI approaches and reports how well each one does.

Which AI strategies are included?

A graph search strategy that finds paths and cycles on the grid, and a reinforcement learning agent that learns the game by trial and error.

How well does it play?

Over 1000 rounds, the README reports an average length of 35.86 and a 94 percent success rate for graph search, and 29.33 and 50 percent for reinforcement learning. The grid is 6 by 6, so the maximum length is 36.

What do I need to run it?

Python 3.10 or newer, ideally in a virtual environment, with the mandatory dependencies installed. The reinforcement learning mode also needs PyTorch.

Can I train my own model?

Yes. The README gives a command to train a reinforcement learning model, and a pre-trained model is also available.

What are the best Snake alternatives?

Popular alternatives to Snake include Tetris Game, Command Line Chess and Jumping-Agent-platform. See all Snake alternatives

Developer Stuff

Badges