Yesterday I joined the latest contest on Coding Game called Unleash the Geek. I spent 3 hours creating and improving my bot and it was a great experience!

It is not the first time that I program for fun on Coding Game. Last time I wrote a couple posts about it:

This time the game consists of two teams of bots collecting ore in a map. The team with the most ore wins after 200 turns or when they all die. Yes, you can kill the enemy robots, or even yourself!

Unleash The Geek (screenshot)
Unleash The Geek (screenshot)

But first you have to parse the inputs, and this is usually a very tedious work, also quite error prone. Luckily they provide Starter AIs in various languages so you can skip the boring part and jump into the game faster.

After copy-pasting the starter code I decided to implement the first most basic moves for an AI to actually look a bit smart cause the sample code doesn’t move at all. So, in order to collect ore you have to find it, go for it and take it back home:

  • Request a radar at the base
  • Place the radar somewhere (a random spot in the map to make things easier)
  • Move closer to an ore and dig
  • Take ore back to base

In order to implement these moves I had to create methods for Cells, Robots and Map. Like cell.isUnexplored(), map.findBestLocationForRadar(), robot.hasOre(), robot.hasRadar(), etc.
Nothing too complex, and that is the best part of it cause adding just a few lines of code actually makes your bot move and do some cool things. But it will do very stupid things too. Mine for example spent most of the time carrying radars randomly around the map because of the findBestLocationForRadar() method being recalculated every turn haha.

But even with those stupid moves the bot managed to win matches in Wood league and progress to Bronze. I think that the difficulty was really well balanced, not too easy and not too hard so you don’t feel overwhelmed.

Bronze was a bit harder. After optimizing radar locations (not too far from base and not too close to other radars) the enemy was still much better. It was time to start adding new moves:

  • Request a trap at base
  • Place trap somewhere to kill an enemy bot

Enemy traps are invisible and will kill any robot that digs in the spot. It makes sense to place them on top of some ore to maximize the chances of an enemy being trapped.

Keeping track of your own traps and trying not to move all your robots towards the same objective worked pretty well and resulted in another promotion: Silver League.

And that was it for the first day. I have some ideas to make my bot smarter today and I will try to reach Gold League when it opens, or at least manage to progress to top 300 Silver.

Join the game and have some fun, it won’t take too much time to do something cool and you will enjoy it for sure: Unleash the Geek.

Read the second part: Unleash the Geek – day II