Battlesnake: play stroopwafel

Battlesnake is a multiplayer snake game where every snake is a program. Both snakes move at the same time, every turn. This is my snake, stroopwafel, compiled from the same C++ as the version that plays on the ladder. There it races a 500 ms clock. Here it gets a fixed number of search iterations, and you get as long as you want.

How it plays

Each turn stroopwafel runs a Monte Carlo tree search over the moves of both snakes. Because the moves are simultaneous, every snake at every node of the tree is an Exp3 bandit, and against another regret-minimizing player that settles toward the equilibrium of the turn. Instead of random playouts, new positions are scored with a flood-fill territory estimate, and the search is steered by priors that like head-to-head fights it would win and avoid the ones it would lose. The weights were tuned by self-play.

It searches the moment a position appears, before you choose, so it never sees your move. After each turn you can see which directions it considered, as a share of its search, and how good it thought each one was (0 = certain loss, 1 = certain win).

Rules are standard Battlesnake: 11×11, health drops by 1 each turn and refills when you eat, food appears at random, the walls kill, and in a head-on collision the shorter snake dies (both die if they are the same length).