At the beginning of May, we held the CodinGame Spring Challenge 2020, a bot programming challenge in the Pac-Man universe. With more than 13k registered players and almost 5000 players in the final leaderboard, it has become the largest competition we’ve ever organized.
So large an event that we created a short teaser for it:
Let’s take a look back at this unprecedented competition on CodinGame held in May.
A Few Stats
About the Game
May 2020 is the 40th anniversary of Pac-Man. As soon as we realized it, we loved the idea of celebrating the anniversary by creating a game based on Pac-Man for our Spring Challenge.
Of course, we added our own style to it. Pacs and pellets to eat, but
- No ghost 👻
- Rock-Paper-Scissors types for Pacs
- Pac abilities to speed up or switch their type
To get a quick idea of what it looks like, I let my colleague Julien explain it in 3 minutes:
The game is now available to play in the bot programming section of CodinGame (with your code already in the arena if you participated in the challenge).
Disclaimer: Different strategies can work at different levels to rank up in the leaderboard. The following is an approximation of what I observed during the challenge.
Getting Started (Wood to Bronze)
- The first and simplest strategy is to move each Pac to a random visible pellet. It can be the same pellet for all Pacs. A very basic strategy, but it allows the Pacs to move in the grid and eat a few pellets.
- The next strategy is to move each Pac to the pellet closest to its position. At this point, checking the Manhattan distance (shorter than the real distance to travel in the grid) was sufficient.
- The last easy strategy is to focus on super pellets. Eating a super pellet is worth 10 turns (or 5 turns if a Pac’s SPEED ability is on). And this is assuming Pacs can eat 10 normal pellets in a row, which is not always possible. So super pellets are really strategic.
Moving Up (Bronze to Silver)
- In the Bronze league, the SPEED ability is probably the easiest to implement. Whenever possible (when the ability cooldown is ready), you can speed all of your Pacs. It greatly increases the number of cells that you reach in the same amount of time and allows you to win battles against players who don’t use SPEED.
⚠️ The classic mistake with the SPEED ability is to command your Pac to move to an adjacent cell, and not two cells away, hence not using the second move.
- With the fog of war appearing in the Bronze league, it is best to keep an update of where pellets have been eaten. So you start with a grid full of pellets and update it with the information given in input and inferred from what your Pacs can see at every turn.
⚠️ Speaking of the line of sight, who got a timeout because they didn’t handle the maps that have a row with no walls (so “infinite” line of sight)? ✋
- After doing that, players usually realize that their Pacs often bump into each other for many turns in a row. At this point, it is probably not easy to implement a strategy to prevent that, especially if you are still using the pathfinding of the MOVE command. But a few if conditions should prevent a lot of useless bumps.
Getting Stronger (Silver to Gold)
- In Silver, most players implement their own pathfinding. You don’t need to explore far in-depth though. Exploring all possible moves for one or two turns (depth of 4) is sufficient to prevent your Pacs from bumping into friendly Pacs or getting eaten too often.
Your own pathfinding allows you to optimize the paths of your Pacs and get more pellets faster.
- It then makes sense to look into the SWITCH ability to be able to defend your Pacs in case dangerous enemy Pacs are close.
⚠️ Moving on to an enemy Pac which has its SWITCH ability means suicide at this level, since SWITCH is resolved before MOVE.
- Silver can be the time to take the dead ends into account. Since exploring deadends forces your Pacs to go back on their tracks, it’s not efficient to go there (at the beginning of the game at least).
Becoming a Legend (from Gold to Legend)
Here, I’m less sure what made the difference, since reaching the Gold league was quite difficult for me 😅
Jokes aside, I advise you to read the forum thread of strategies; it’s very insightful.
The right thing to do to make it to the Legend league is to have a good search algorithm to perfect your pellets’ farming. Properly tracking your opponents (and the pellets they eat) turned out to be quite complex and not always successful.
Saelyos, the winner of the Spring Challenge 2020, shared his strategy on GitHub.
A Community Event
The Competition as a Learning Experience
“TBH, this was extremely fun and I enjoyed every bit of it. There were too many things that I thought I knew, but turns out I barely scratched the surface. I had to learn way too many things that I’ve never encountered before. Definitely a better learning experience than all my school years combined. Looking forward to more competitions in the future!”
Giving your best in a coding competition often pushes you to discover and learn new things.
Reuniting with a Friend for a Great Result
Playing with friends and sharing strategies with them is a good way to keep your motivation high.
Insufficient almost gave up after reaching rank 600 mid-challenge, but his friend joining the competition changed it all. He finally reached rank 47 in Legend!
“Thanks to CG for this fun challenge – and thanks for bringing me and my old friend together again – it felt like we were 18 again bouncing ideas off each other and discussing theories together.”
If you’re lacking the motivation to continue coding, just reach out to your friends or to the community players on the chat or Discord!
For this competition, YannT set himself a challenge of his own: to reach the Legend league with the simplest possible bot. And he made it! His Kotlin bot reached Legend with only 300 lines of code.
As he explained his strategy in the forum, he didn’t focus on reducing the number of lines with golf tricks. It should even be possible to trim his code down to 200 lines of code without hurting readability much. Impressive 👏🏻
Fast & Furious
This is what I call being super-efficient. Michael_Howard joined the competition 2 days before its end and reached the Gold league. Congrats!
“So many things I had no time to do, like proper pack-hunting & changing strategy based on how the opponent plays. Wish I’d come along a week earlier!
So, 383/4976, #2 in Swift. I’d have loved to reach Legend just to learn from the best bots and get a sense of what is possible.”
Streaming and Playing until the End
During the Spring Challenge, we had the pleasure and the honor to have Instaffluf stream his progression in the competition on Twitch. Part of the awesome Live Coders stream team (you may have heard of CJ, who regularly plays Clash of Code and who is on the team, too), he loves to code on stream and hang out with the viewers.
This discussion happened one hour before the challenge closed in Instafluff’s Discord server:
I just submitted again
hopefully the RNG gods will help
okay rng come on 😂
So many tough bots! I don’t know if I’ll even end up in the top 100
I came back to falling down to #3 😂 hopefully it can get to gold before the end of the comp cuz that’ll add a lot more points to our team
I think I’m done. Not sure what else I could get done within an hour :joy:
hope it was a lot of fun for you too!
It was!! I missed doing this kind of coding a lot
I think we could do more of these multi games on stream because I’d love to revisit some of the other ones that I’ve worked on before
Thank you for the streams, Instafluff! They were lots of fun and entertaining to watch 😍
I’d like to thank all the players who shared their progression on stream, too (hope I’m not forgetting any). You contributed to making this challenge a great event for the community. Keep up the great streams!
– thibpat (JS)
– cegprakash (C++)
– grsoares (JS)
– HexTree (Python3)
– glitch (Java)
– fr3ddyf (PHP)
– SaintPlaysThings (JS)
– Savin Vadim (Java)
– SanaRinomi (JS)
– h25 (Python3)
– JBM (Haskell)
– Cyber_Caw (Python3)
– Daan Breur (JS)
Replay of the Week
Perfectly timed with the music…wait for it…!
Thank you tutubalin for sharing this fun video.
Dev Communities Uniting
One year ago, Zylo created a Slack with some friends for CodinGame’s Polish community. During the challenge, it became a place for sharing ideas with more and more Polish players. In particular, aCat and Zylo organized a stream session to help others to reach the Gold league.
This probably made the difference for the University of Wroclaw to win the school challenge. Well done!
Did you know that Twitter was the first Social Networking Service in Japan? Well, it was a pleasure to see so many players tweet about the challenge:
I couldn’t follow everything, though 😅
Congrats to all the Japanese players (18 in Legend!); it was great having all of you.
Feel free to join the CodinGame Discord server. All channels are in English, but we create language-specific channels, too.
Mob Programming as Practice
At Société Générale, under the expert guidance of [SG]Bisou, they have experimented with mob programming to introduce CodinGame to beginners and help them prepare for the challenge.
They coded together a few times on Tron and Back to the Code over the past few months. They got together at lunchtime, with colleagues spread on different sites (or at home during the confinement) following the progress by conference call.
During the challenge, they only shared strategies. Congrats for the 3rd place in the company challenge!
Thank you to all the players who joined the challenge and made this challenge the greatest event on CodinGame!
I’ll share news about the next upcoming challenge as soon as I can. You can also register for it.