Emil SundmanSvenska

LinkedSnek

An early Unity/C# project exploring linked data structures, hex-grid representation, breadth-first-search pathfinding, and a working AI/autopilot mode.

Project context

LinkedSnek was an individual Unity/C# course assignment focused on data structures and algorithms. I later expanded it with an independent AI/pathfinding experiment on the same game board.

The project uses Unity 2020.3.16f1 and represents the game on a hexagonal grid rather than a conventional square Snake board.

What I implemented

I wrote GridScript, Snek, and SeekerScript. The grid uses cube coordinates (q, r, and s, where q + r + s = 0) and supports movement across the six neighbouring hex directions together with boundary handling.

The snake body is represented as recursively linked Snek components. Movement propagates through the linked segments, and growth instantiates and links additional segments.

BFS pathfinding and AI/autopilot

I implemented breadth-first search with early exit from the snake position to the food target. The search stores visited nodes in a cameFrom map and reconstructs the resulting path after reaching the target.

During development, LinkedSnek had a finished, working AI/autopilot mode that used this BFS pathfinding to navigate the snake toward the food. The preserved repository snapshot has the final SnekAutoPilot integration commented out, while the BFS and path-reconstruction implementation remains preserved in SeekerScript. The autopilot should therefore be understood as a finished mode that worked during development, not as a permanently enabled or default gameplay mode.

Source

The historical implementation is available in the public GitHub repository.