DEV Community

Cover image for πŸ•ΉοΈ Retro Revival: Pitting Human vs. A* Search Intelligence
Shyamli Khadse
Shyamli Khadse

Posted on

πŸ•ΉοΈ Retro Revival: Pitting Human vs. A* Search Intelligence

πŸš€ The Vision

For this week's challenge, I decided to breathe new life into the 1976 classic, Snake. The goal wasn't just to recreate the nostalgia of the Nokia era, but to introduce a Modern AI Twist: a competitive "Ghost" snake that uses high-level pathfinding logic to outsmart the player.

🧠 The "Modern Twist": Complex AI Logic
The heart of this project lies in ai.js. Unlike original arcade games that used simple "if-else" logic, my version implements the A (A-Star) Search Algorithm*.

How the AI Thinks:
The AI treats the game canvas as a grid of nodes. Every 100ms, it performs a search to find the shortest path to the food. It calculates the Manhattan Distance to prioritize moves:

                d = |x_1 - x_2| + |y_1 - y_2|
Enter fullscreen mode Exit fullscreen mode

By assigning a "cost" of infinity to pixels occupied by snake bodies, the AI dynamically navigates around the player in real-time.


πŸ› οΈ How Kiro Accelerated My Build
The Kiro IDE was more than just a code editor; it was a lead engineer. Here is how it accelerated my development:

Algorithmic Scaffolding: Writing A* from scratch is error-prone. Kiro generated the initial class structure and heuristic functions based on my plan.md.

The "Straight Line" Fix: At one point, the AI snake would only move in a straight line. I shared the code with Kiro, and it identified that the target coordinate wasn't being refreshed inside the requestAnimationFrame loop.

Retro Styling: Kiro helped me write the CSS for the CRT Scanline Effect and the Windows 95 beveled buttons, giving it that authentic "Retro Revival" look.

πŸ“Ί Visuals & Results
The final result is a seamless blend of 90s aesthetics and modern search theory.

UI: Windows 95 Teal Desktop.

Logic: Real-time adversarial pathfinding.

Proof of Work: All development logs are stored in my /.kiro directory.

"Kiro allowed me to focus on the high-level game design while it handled the complex matrix math required for the AI's brain."


πŸ”— Project Links
GitHub Repository:(https://github.com/kshyamli/Retro-Revival-AI-Enhanced-Snake)


Top comments (0)