The battles are fought one-on-one over 2 minutes. The bots are circles shooting smaller circular bullets. Each bot is able to perform the actions move, rotate, and/or shoot every 75ms and knows the position of the enemy and all bullets every tick. The bots each have 5 lives and can have 5 bullets on screen at once. The tournament is single elimination and the prize is some token gifts and bragging rights.
This year instead of hand-coding a bot I decided to try my hand at writing an Evolutionary AI program, which I’d been fascinated with after seeing this AI learn to play Mario all by itself. Could I create and train a bot good enough to defeat the Human created bots?
Now I’m no AI expert, and this bot isn’t going to beat Alpha Zero any time soon. It’s pretty simple in it’s implementation. It’s a neural network that starts with some input nodes and output nodes, then randomly adds nodes, links between nodes, changes the weights for the links and disables/enables nodes. It’s based off the Evolving Neural Networks through Augmenting Topologies (NEAT) paper. Each neural network is called a genome and they are organized into species of similar genomes. When a genome performs well in battle it gets a high fitness rating and then goes on to have new child genomes with random mutations. If a genome performs poorly it is eliminated. The inputs to the neural network are the position of the walls, bullets, and opponent, and the outputs are the actions the bot should take.
You can train in headless mode and it will run hundreds of battles in parallel, scaling to as many CPU cores as your PC has. During training you can watch the latest generation fight it out in your browser. After making the bots train by fighting each other for a few hundred generations the bots are able to fight at a decent level. I entered a bot with around 600 generations of training into the tournament and it ended up making it through the first 2 rounds and being eliminated in the 3rd.
Rather than let that code go to waste I thought why not open source what I’ve made, and create a custom battle environment so others can learn how an Evolutionary Neural Network works and build their own AI’s. So I’ve done that as well as written an in depth explanation of how everything works in the README and thoroughly documented the code. You can check it out here. Enjoy training your own bot to use in your next game of battle bots and good luck!