# a game and a challenge

Recently, I attended a programming camp. At the end of this camp, we all competed in a competition for fun. In this competition, we wrote bots that played the well-known and highly regarded game, er, ToonSplat. These bots competed against each other in a round-robin tournament.

ToonSplat is a game which occurs on a ten by ten grid. Each player has 8 'botlets'. Your botlets all start at (0, 0), while your opponent's start at (9, 9). In each tick, these botlets either move to an adjacent grid square or stay where they are. Many botlets can coexist in one grid square. At the end of the tick, each botlet will "paint" the square it is in its team's "colour". If there are both enemy botlets and friendly botlets in a square, the team with more botlets in the square will succeed. (If there are an equal amount of both, it will be set to the initial, unpainted state.) After that, each team will receive an amount of points equal to the amount of squares painted it's colour.

The winner is the one with the most points after 100 ticks.

There are also a number of implementation details to be aware of. The bots are written in C++, and should implement 2 functions, `init()` which is called for initialisation and `tick()` which is called on each tick. Within these functions, you may call the `move()` function, which adds a position and a mode to a botlet's "move queue" (which may be freely inspected, since it is an argument to tick()). On each tick, each botlet will move once towards the first position in its "move queue" in a manner defined by the mode, and then remove that position from the queue if they have reached it. In mode 0, it will first move horizontally, and then vertically. In mode 1, it will first move vertically, and then horizontally. In mode 2, it will move randomly but optimally.

There is also a function `cancel_all_operations()`, which will clear a botlet's move queue. More documentation is available in the file `toonsplat.h`, linked at the bottom of this post.

## come back in ten years, kid...

Now, I don't mean to brag, but I won that competition. My bot, Flyrocket, was undefeated. My challenge to you, dear readers, is to create a bot capable of defeating Flyrocket. The resources you will need to develop this are linked at the bottom of the post. Your bot must be compiled using ```g++ bot.cpp grader.cpp -O2 -o bot``` or similar, and then can be tested against another bot by running ```python3 judge.py ./bot ./bot2 ./replay.json```. You can look at the replay in the visualizer here on the website, or you can download that page and look at replays locally.

If you develop a bot that consistently defeats Flyrocket, email me and you will receive some nonspecified prize that likely just amounts to a warm and fuzzy feeling.

## credit

Credit for all code in this post except for Flyrocket goes to the tutors for the camp I went to.

back