This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

RcCookie presents ...


Snake AI

This is based on my 'Snake V2' scenario. This time however, the snake is controlled by an ai.

The ai is using the A* search algorithm to find its path. You can see that it runns rather slow when trying to find a d-tour, thats the nature of the A* algorithm.

The AI isn't perfect, if there is no path at the current point in time, it will propably go straight into a wall. I might fix this in the future.

10809 views / 10061 in the last 7 days

2 votes | 0 in the last 7 days

Tags: game simulation demo with-source snake ai search smart

open in greenfoot
Your browser does not support the canvas tag.
A new version of this scenario was uploaded on 2020-09-24 15:33:09 UTC
A new version of this scenario was uploaded on 2020-09-24 15:39:44 UTC Updated restart time


I should save this scenario‘s highscore also to the other one


It looks like the snake will kill itself if it can't find a path to the food. Maybe you should try to simulate the tails decay when doing the pathfinding.


Yeah I know. It basically just goes straight if it doesn’t find a path

Want to leave a comment? You must first log in.

Who likes this?

Roshan123 Game/maniac