Snake Battle – AI Pathfinding Snake Game

Snake Battle is a desktop game inspired by the classic Nokia snake but reimagined with artificial intelligence. Developed in Java using Swing, it features two autonomous snakes that compete to reach 20 glowing food pellets first, intelligently navigating the board while avoiding collisions with walls, themselves, and each other.
- Functionality: Two AI-controlled snakes race to eat 10 balls. Game-over triggers upon winning or fatal collisions. Dynamic, flickering target ball with a retro-style glint.
- Visual & UX: Clean 30x30 grid board, rounded snake body with eyes, flickering glowing food pellet, live score tracking.
Technical Details & Architecture:
- Java + Swing: Built as a fully native desktop GUI application.
- AI Logic: Real-time decision-making using BFS (Breadth-First Search) pathfinding.
- Path Safety: Snakes avoid walls, bodies, and opposing snake heads via predictive logic.
- Game Loop: Timer-based system running at 150ms intervals.
- Randomization: Snake spawn and ball placement avoid collisions and overlap.
- Modular OOP Structure: Cleanly separated into Snake.java, Ball.java, GameController.java, PathFinder.java.
This project showcases OOP, intelligent pathfinding, and real-time UI rendering. With nostalgic design and smart behavior, it stands out as a portfolio piece that demonstrates algorithmic thinking and GUI development in Java.
Back to Projects