Entering the Battlesnake competition

A sport for professional programmers


BATTLESNAKE

Introduction

In 2019, I came across this programming competition called Battlesnake.  I learned that Battlesnake started in Canada, and has been growing internationally for 5 years.  Here's how Battlesnake describes itself:

Build a snake bot and compete with other developers

Step 1: Write a program to play the game Snake
Step 2: Deploy using whatever technology you like
Step 3: Battle other snakes and compete in arenas!


Participation

Once it became clear that Battlesnake is a professional sport for established programmers, I wanted to play!  I found that it was really easy to register as a Battlesnake player, and to program a snake that can compete.

The game of snake is a turn-by-turn board game with a snake that you can move up, down, left, or right.

The first challenge was to program the snake to not run into a wall.  That was easy.  I did it in 4 lines of code: one for each wall.

The second challenge was to program the snake to not run into its own tail.  That wasn't very hard.  But when I did that, I found that the snake could trap itself in a tight space and have nowhere to go.

The third challenge was to program the snake to see enough moves in advance so that it would avoid going in a direction that will trap itself.  This was a bit harder but it was my first major milestone.  As soon as I completed this third challenge, my snake had the ability to play a "perfect" game.

The animation to the right is the actual game that my snake played "perfectly" by filling up the entire board without any mistakes.



My first "perfect" solo game.


Competition

Once I had a good handle on how to build a snake that can survive in solo mode, I wanted to play other snakes!

As the snake's programmer, I started turning losses into challenges.  For example, when the snake and I lost because we ran into another snake's head, we took it as a challenge to program ourselves to avoid moving to squares that could end up creating a head-on problem.  Then, if we lost because we didn't take the opportunity to make a head-kill, that created a challenge to program ourselves to initiate offensive strikes.

We started to follow an improvement process called Plan Do Check Act, where we would play a game, check for opportunities to make a better move, and modify the code in iterations.

Upon entering our first competition, we named ourselves after this improvement process.  The following video shows how we did on the first day that we entered the Battlesnake competition:







Copyright (c) 2019 by Harry B. Garland.  All rights reserved.  Videos and animations from the Battlesnake competition are copyrighted by Battlesnake Inc. and are included here in accordance with Fair Use laws and international treaties.