Skip to content

Using the A* pathfinding algorithm to play the classic snake game perfectly

Notifications You must be signed in to change notification settings

CodeAltus/Snake-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snake AI

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

Implementation

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.

Demo

You can see my Snake AI in action at https://codealtus.github.io/Snake-AI/

Disclaimer

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!

References

About

Using the A* pathfinding algorithm to play the classic snake game perfectly

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published