Role: Programmer
Category: AI
Engine: Unity
Team Size: Solo
Time: 2 weeks
Implementation of Snake's AI with A* pathfinding and weighed pickups. Simulation can be run with or without user having a controlled snake.
Feature: | Description: |
---|---|
Grid Generation | Grid map generator with neighbour checking |
Screen Wrapping | Screen wrapping on map's edges |
Linked List | Implementation of linked list used in snakes |
A* Pathfinding | A* pathfinding for snake's AI with weighed pickups |
Snake Slicing | Break snake's linked lists in runtime |
Finding the neighbours of each tile is essential for true grid movement which was my goal for this project. In this case, only 4 positions need to be checked around the tile since there's no diagonal movement.
Since the movement is already constraining that a snake's next move can only be to a neighbour tile, setting up the neighbours on the edges to be on the opposite edge is enough for the screen wrapping to work.
There's three types of pickups: Snake's dead body, fruit and a blue fruit. These pickups have different weights that will affect the snake's decisions when deciding on a path. This is done by adding this weight to the cost of the tile where the pickup is placed.