◀ VibeCruiser

Snake AI

A free snake game — play it in your browser, no install. Using the A* pathfinding algorithm to play the classic snake game perfectly

by @CodeAltus · CodeAltus/Snake-AI on GitHubLANG JavaScript★ 17HOSTED ON CODEALTUS.GITHUB.IOUPDATED 20 May 2021

Vote and save it — free account with email or sign in with GitHub

Made this, @CodeAltus? See how many people played it → or use email

▶ Play full screen ▲ Vote: free account with email ▲ Or sign in with GitHub

GitHub may ask you to sign in, then to let VibeCruiser “Verify your GitHub identity” and “Act on your behalf”. We only read your profile and email, and never post anything.

Open the live demo Source on GitHub

From the README

I created the PERFECT Snake AI using the A* pathfinding algorithm!

The A* pathfinding algorithm was used to find the longest possible path between the snake's head and snake's tail. The apple is always on this path and it is eaten as the snake travels on this path. The snake is also never trapped as the snake's body leaves a way out for the snake's head. This program usually takes 1 hour to run.

You can see my Snake AI in action at

I have run the AI ten times and it has worked perfectly but I can't be too sure if it is absolutely perfect. Feel free to use my code!

Read the full README on GitHub →

Built something like this? Submit your vibe — free account, takes a minute. How listing works.

More like this

More snake games →

Made this?

Claim it: create a free account, then press CLAIM THIS in the cruiser. Put the badge below in your README or on your demo page first; that link is how we know it's yours.

Your project is on the cruise, loaded live from your own site. Put the badge in your README or on the demo page: it shows your live play count, it links back to this page, and everyone who lands here is one click from running the real thing.

On VibeCruiser

How listing, the badge and claiming work →