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

Report as inappropriate.

RcCookie
RcCookie presents ...

2020/9/24

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.

10967 views / 10219 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
RcCookieRcCookie

2021/2/3

I should save this scenario‘s highscore also to the other one
Game/maniacGame/maniac

2021/5/2

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.
RcCookieRcCookie

2021/5/2

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