Loading repository data…
Loading repository data…
ImBIOS / repository
Run for your life! A reverse take on the classic Snake game where YOU are the apple and the AI snake is hunting you. Built with vanilla JS & A* Pathfinding.
Survival Horror in 8-bit. The classic Nokia snake game, inverted. You control the food, and the Snake is an AI determined to eat you.
👉 Click here to play the live game
Reversed Snake is a free, open-source browser game built with Vanilla JavaScript and HTML5 Canvas. It flips the script on the classic retro arcade game: instead of guiding the snake, you play as the Apple.
The Snake is controlled by a sophisticated pathfinding algorithm (A* Search) that ruthlessly hunts you down. As time passes, the snake grows longer automatically, making the grid increasingly claustrophobic.
Level 10 features a "Swarm Mode" where you must dodge 10 intelligent snakes simultaneously, making it one of the hardest snake game variants on the web.
This project is a perfect example of game development with pure JavaScript (no engines like Unity or Phaser).
The snake utilizes a PriorityQueue to calculate the most efficient path to the player's coordinates. To maintain 60FPS with 10 snakes, the game uses a Collision Grid Cache (O(1) lookup) instead of checking every snake body segment individually.
function findPath(start, goal, snake) {
// Manhattan distance heuristic
const heuristic \= p \=\> p.manhattan(goal);
// ... implementation of A\* loop
}
Want to modify the AI or add new skins? No build steps required.
# Clone the repository
git clone https://github.com/ImBIOS/lab-snake-reverse.git
# Navigate to directory
cd lab-snake-reverse
# Open in browser
open index.html
Keywords: Reversed Snake, Play as Apple, Snake Game AI, Hard Snake Game, A* Algorithm Game, Browser Game, HTML5 Game, Survival Game, JavaScript Game Project, Open Source Game.