↖ ALL WORK
PROJECT 03 / Algorithms & desktop2025

Snake Battle

Two snakes. One smart little rivalry.

An autonomous head-to-head snake game. Breadth-first search and predictive collision avoidance turn a familiar game into an exercise in decision-making.

Java desktop game
Think
ahead.
BREADTH-FIRST SEARCH / JAVA + SWING
THE BUILD

Java desktop game

JavaSwingBFS
2025 / Algorithms & desktop
01 / THE QUESTION

The challenge.

Two autonomous agents need to reach food while avoiding walls, their own bodies, and each other in a changing board state.

02 / THE RESPONSE

Inside the build.

Breadth-first search finds routes to the target. Predictive safety logic checks opposing heads and obstacles, while a Swing timer updates the game loop at 150 ms intervals.

01

Swing game board

02

GameController

03

BFS PathFinder

  • 30 × 30 game board with live scores
  • Predictive collision avoidance
  • Separate Snake, Ball, controller and pathfinder classes
  • Collision-safe spawn and target placement
EXPLORE THE PRINCIPLE

A path to
understanding.

A browser experiment illustrating the BFS principle used in Snake Battle. The original game uses Java, a 30 × 30 board, two snakes and collision prediction; this editable grid isolates the search algorithm.

LIVE EXPERIMENT / BFS0 NODES VISITED
START TARGET WALL VISITED

Place obstacles. Move the target. Find a way through.

KEEP EXPLORING / 043D Tree Portfolio
LET'S MAKE A CONNECTION

Hello, there.