OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Snake

A public MIT-licensed Python research project implementing two AI approaches for playing Snake: graph search and reinforcement learning.

Independent OpenViST project profile, based on linked sources.

Snake — OpenViST project profile in AI Developer Tools & SDKs.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use it when a small, executable game environment is useful for comparing rule-based search with learned behavior or for studying AI implementation details.

Who it is for

  • Developers exploring game AI
  • Students learning search and reinforcement learning
  • Researchers comparing gameplay strategies
  • Readers seeking a compact executable AI experiment

Documented uses

  • Run a graph-search Snake agent
  • Play Snake with a reinforcement-learning agent
  • Train a reinforcement-learning model
  • Compare documented outcomes for two AI approaches
  • Study path planning, rewards and game-state decisions
Before you choose

Requirements & limits

The repository is public and marked active in the supplied record. It is written in Python and licensed under MIT. The documented setup requires Python 3.10 or later; PyTorch is additionally needed for reinforcement-learning play or training.

  • Choose graph search for the repository’s rule-based path-planning approach, including Hamiltonian-path and tail-safety checks.
  • Choose reinforcement learning to examine a neural-network agent trained through rewards and penalties with Double DQN.
  • The documented environment is a 6×6 grid with a maximum snake length of 36.
  • The repository includes a pre-trained reinforcement-learning model as well as a documented training command.
  • Reported example results differ between the approaches: graph search has higher documented average length and success rate than reinforcement learning in the cited README table.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Set up and run the documented Snake examples

Install the Python project and start its graph-search or reinforcement-learning game modes.

Before you start

  • Python 3.10 or later
  • A virtual environment
  • The project dependencies
  • PyTorch for reinforcement-learning play or training

Steps

  1. Create and activate a virtual environment with the command below and source venv/bin/activate.

    Documented command
    python3 -m venv venv
  2. Install mandatory dependencies with the command below.

    Documented command
    pip3 install -r requirements.txt
  3. Run the command below to play with graph search.

    Documented command
    python3 main.py
  4. Install PyTorch according to the CPU or GPU setup, then run the command below for reinforcement-learning play.

    Documented command
    python3 main.py -m rl
  5. Run the command below to train a reinforcement-learning model.

    Documented command
    python3 rl_train.py

Expected outcome

The project is installed and its documented graph-search or reinforcement-learning mode can be started.

Guide limitations

  • The documented game uses a 6×6 grid.
  • PyTorch is an additional requirement for reinforcement-learning play and training.
  • The README documents commands and example results but does not establish performance beyond its reported 1,000-round examples.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
30 September 2026
Original website title
chynl/snake · Official homepage title · retained in its source language