Four weeks ago, more than 3,500 programmers joined the online programming contest Coders of the Caribbean, aka “CotC.” At the time I write this, the Code4Life competition is still ongoing. I’m pretty sure a lot of programmers see such contests merely as fierce competitions between passionate –crazy?– developers who excel at writing AIs designed to be efficient at a specific game. You might even be telling yourself that you’re not cut out for these coding competitions, as you’re not too much of a competitor.
But there’s much more to it. Here’s what you’re missing.
#1 Learn from The Best
Don’t we say that developers should never stop learning? The top 3 players of each contest usually share their strategies in postmortems. They also share part of their code. Actually, many other developers from the top 100 players like to explain how they achieved their rank. There is no better opportunity to learn from your peers; what are you waiting for?
You could start with the postmortems of Agade and reCurse for CotC:
Scores of players have shared their feedback and strategies in this forum thread.
#2 Fun & Challenging
Obviously inspired by the next upcoming movie of the Pirates of the Caribbean franchise –Dead Men Tell No Tales– CotC staged a naval battle. Each player had to properly maneuver their ships to avoid enemy cannonballs and retrieve barrels of rum scattered across the sea. All of this on a hexagonal grid; a classic checkered grid would have been too boring.
This hexagonal grid greatly increased the difficulty of the game. As Manwe realized, the distance between a ship and a barrel of rum can make a tremendous difference in the time it will take that ship to reach that barrel. It depends on the initial speed and orientation of the ship. Below are some of the maps Manwe computed to show the “sailing distance” (until the boats reach speed 2):
It’s funny to realize that a ship with a speed of 2 will take 6 turns to reach the cell behind itself. This hexagonal grid was clearly a new challenge for competitors.
#3 A Vibrant Community
During a contest, the chat activity almost doubles. If you’ve got a question, this is the best place to get a quick answer. Despite the competition, the coders there are really helpful. Of course, don’t expect them to share their secret strategy; however, you could definitely learn some useful tips there.
“This was my first CG contest and I quite enjoyed it, especially the very helpful chat #general_de. Shouts out to @eulerscheZahl, @schubc, @DerRadikaleRusse, @mmmd and others!”
Besides the helpful atmosphere, you’ll find a lot of programmers like yourself on the chat, eager to share their joy at being promoted — or their frustration over the performance of their bot. You’ll see, you’re not alone!
You might even be lucky enough to live near a place where competitors eagerly meet together for CodingHubs. Spend some time with fellow programmers, discuss the contest and compare strategies…
“Meeting other people at a CodingHub made for a very good evening.”
#4 A World of Sharing
Some programmers have created useful tools to help them test their code and understand how their bot is behaving. They’ve been kind enough to share them with the community. Here are the 3 main tools that you can use during a contest:
- The CG Stats tool created by @Magus allows you to obtain some statistics about your AI’s matches in the arena.
- The CG Spunk browser extension created by @player_one enables you to run a batch of matches against different AIs.
- The cg-brutaltester tool created by @Magus is a Java local tool to simulate the CodinGame multiplayer IDE.
Also, if you’re interested in Scala, TrueLaurel has developed a Scala kit for coding contests. He’s kindly shared it with everyone interested, and he even streamed to showcase it. Congrats to him; I know how difficult this can be, especially alone.
Finally, you might have missed the Manwe’s famous talk at Devoxx France, but it’s now available on YouTube. He shared the tips he used to become legendary at a coding competition; enjoy!
#5 Unexpected Strategies
When a game involves rum, anything can happen. Not only did you have to shoot cannonballs at your opponent, but you also had to find barrels of rum drifting on the sea to prevent your crew from going mad. When a ship was destroyed, a rum barrel would be left on the sea.
Marchete was pleasantly surprised to discover that his genetic algorithm decided to sacrifice his own ship on a mine –yes, there were also floating mines– so another one of his ships could get stronger by collecting the remaining rum.
Employing a similar strategy, his bot decided that one of his ships should shoot another doomed one to retrieve the needed rum.
In a previous contest, Fantastic Bits, involving a kind of football game, smart AIs would make the ball collide with the edge of the pitch to score instead of directly targeting the goal.
#6 Improve Useful Skills
Sure, what you code during a coding competition is somewhat different from what you code at work. Still, such a competition can benefit you more than you think. First, tests. Who would write tests during a contest? Writing tests actually helps players save time. And time is a precious resource during these contests.
“Write tests! The fuzzer test was the key. I recommend it to anyone. It was just 10 lines to write but found me several bugs.”
Pretty funny advice considering the username!
Another domain in which a coding competition can help you is in the management of your time (and stress). Just like in real life, you cannot afford to spend too much time on some parts of the code. You’ve got deliverables, and being late could be a problem. In a coding competition, the quality of your code becomes a constant trade-off between readability, performance and time to write it.
At the end of the day, a contest pushes you to solve a complex problem. You will need to break it into several subproblems that you know how to solve. Just like what you encounter every day at work.
#7 It (usually) Comes Back
What you’ve worked on for several hours is not lost. You can continue to improve your bot once the game is released on the platform. And now is the time: we’ve just opened the new multiplayer game Coders of the Caribbean!
A note about code sharing: a contest remains a competition. Sharing the code of a really good AI on Github can deeply disturb the leaderboard. We’ve unwillingly disqualified Kodle for this reason. I’d like to thank him for his positive response; you can read his postmortem in the forum thread discussed above.
And, last but not the least, sharing a full working AI capable of reaching the top 100 can greatly harm the competition of the multiplayer game, so please, keep this in mind!
I hope I managed to convince you that a coding competition is not just a competition. Our next contest, Wondev Woman, arrives in late June, so you’ve got some time to practice.