(root)/Sandworm/WRITEUP.md

Sandworm

A competitive Battlesnake running minimax over Voronoi 2025-10-11

Project Readme • Project Files • GitHub Repo • move.c

See the readme for a summary of Battlesnake and for an overview of the algorithms powering Sandworm.

Writing a Battlesnake in C had been in the back of my mind for a little while. As a matter of fact it was the initial motivation for writing JSONW. Last month, Carleton University’s Computer Science Society organized a one-day Battlesnake hackathon, and I figured it’d be a good opportunity to write a Battlesnake without the risk of another project landing on my plate. Naturally, by the submission deadline my snake was unreliable and full of bugs, so I ended up with another project on my plate anyway.

Debugging all the bitboard masking and bit shifting operating over state information that’s mutated entirely in-place was a nightmare. And extracting useful information from a tree search algorithm is difficult because any given line of code is likely to be run millions of times each search. I have the Common Gateway Interface (CGI) to thank for my sanity, because it meant:

  1. Bugs couldn’t originate from what would’ve been a shoddy attempt at hacking together a makeshift HTTP server;
  2. Reproducing a bug was just a matter of saving the request body to a file then piping it into move.c’s standard in.

As of the time of writing, Sandworm ranks 4th out of 500+ snakes on the standard leaderboard and 5th out of 400+ snakes on the duels leaderboard. And that’s with no smarts, just raw single-threaded C99 on -O3 running textbook minimax.