Asteroids JS Cooking Game Course

Snake Algorithm

Autumn 2019

I recreated the classic Snake game, allowing user control, and then integrated a pathfinding algorithm to govern the movements of the snake player.

JavaScript
P5
Collsions
AI

Key Features

Challenges, solutions and lessons learnt

My primary challenge was pathfinding around the snake's tail. However, this problem becomes significantly easier if you approximate the tail using a fixed grid and pathfind around it. To further enhance this approach, I would consider caching distances to food within the grid and updating the grid based on the new gap created by the end of the tail. This would allow for the recalculation of information only as necessary.

Embedded Game

Placeholder Image