See it on the leaderboard
This is my first battlesnake. It's a C program with Python handling the web requests.
This snake is stateless, the core of the program is made of a series of 50+ if/else statements that reflect diferent possible situations on the board. Each turn, one of the situations is matched and the snake makes the corresponding move. A series of helper functions analyze the situation to provide data for the decision. I built this snake iteratively, starting with simple collision avoidance. After that I implemented food tracking. Next was avoiding the heads of larger snakes to avoid headon collisions. The most complex function is a pathfinding problem that's trying to solve a variation of the np-complete hamiltonian path problem. As the snake doesn't have nearly enough time to compute the entire grid, it stops after about 30 levels, which provides effective survival pathfinding. To make the snake more aggressive, it chases smaller heads in an attempt to force a collision. It also detects when a snake has nowhere else to turn or when it's against a wall, and actively moves to trap it.
I originally wrote this snake in Python but as the code became more complex I converted it to C. Now, Python handles web requests and uses the library functions to create C objects and pass them to a compiled C program.
This challenge presented a unique experience in pathfinding, problem solving, and optimization. I look forward to improving Mithrandir and participating in future competitions.