Now that I have participated in 4 CG challenges, some patterns have started to emerge.
There are two problems I consistently run into that are really different symptoms of the same root cause.
I start slow, organize my code thoughtfully in classes/modules/components, write tests, use local simulations and visualizations. All of this makes it a lot easier to reason about my code and make changes and improvement. But when I take this approach I usually run out of time to actually iterate on the bot’s algorithms.
I start fast, write shit, buggy, procedural code, get the bot to not half bad… but when trying to get to the next level I start getting lost in the code and bugs get in the way. So I start refactoring… and run out of time.
Either way, I always run out of time. It would be awesome if the challenges were a bit longer. But I digress. I’m interested to know what kind of code all of you write during CG challenges.
Do you code in CG’s IDE or do you code in your local IDE?
Do you organize things in multiple files/folders/classes/modules or do you just do one big block of procedural code?
Do you ever struggle to keep your code within the 100kb limit like I do?
If and when you go back to your code months later, are you completely lost or is it organized well enough that you can pretty much pick up where you left off?
Do you see the code you write for CG challenges as throwaway code or do you try to write code you wouldn’t be totally embarrassed to show to a colleague?
If you have participated in a few challenges, what do you find is your biggest obstacle to improving your bot the way you’d like to?
I code in pycharm for python and use CG plugin to sync with the online IDE
I start by building the classes/models for any data i know and anything i can immediately extract that i think will be useful. I aim to reduce the times i make the same calculations by storing it once, then accessing it.
I would like to use multiple files, but haven’t found a nice way of loading it back into CG, so i use 1 big fill and squash things that i consider “stable”
Python is typically short. EVen with all my excess comments and commented code, im currently on 62KB with 1400 lines. tbh, i didn’t even know about the limit as ive never hit it.
I like to comment, im all about readable maintainable code, so even when im being hacky its normally readable later.
I definitely see my codingame code as pretty throwaway and not something i would use commercially. But that said good code, is good code.
My biggest obstacle is my lack of knowledge. Seriously. I know i don’t even know what i don’t know
I use a local IDE (MonoDevelop) and copy-paste the code to the CodinGame website.
Multiple files. I configured my IDE to run a script after each build. That merges multiple files into a single one which I can then use for CodinGame. I spend some time to get my tooling working, see this tech.io playground on the debugging aspect.
I’ve never came close to that limit. My largest bots are around 1600 lines and 50kB.
I can’t continue instantly but understand what I did when I give it a few minutes.
A throwaway code but that doesn’t stop me from showing it to others.
Lack of motivation to spend much time on complicated features that would probably result in a small improvement. And sometimes I realize that I started with a bad approach but it’s too late / too much work to revert that decision.
I can’t speak about competitions since I don’t sign up for them but I really like writing bots outside of it.
The main reason being: I’m a bit slower than others when it comes to finding some working solutions so I like to take my time.
Answering your questions:
I use pycharm / visual studio and merge scripts for working with multiple files
Usually it takes some time to read the code once I haven’t touched it for few months, but it’s quite easy to understand
I’ve run into the code limit issue once, but a bit of refactoring helped.
My biggest struggle is implementing small features which surely would improve my bot, but not in a very noticeable way. I’m sometimes a bit too lazy to create game engine and test my bots on my own, which would be helpful.
Once I reach legend I usually struggle to improve my bot for the most strange reason – afraid of losing ranks
My usual strategy is to write a messy code to get into bronze league and then switch into a structured code with classes and helper methods - trying to focus on mostly biggest impact changes, and moving onto smaller things as I advance the ranking.
Local IDE (Visual Studio Code). I copy/paste my codes in the CG ide everytime i want to test/submit it on CG.
I use only one file but it’s organized in multiple classes/modules. I have also a bunch of utility classes that i can copy/paste in my code.
Everytime I open an “old” code on CodinGame, I can swear this is the worst code I have ever seen in my entire life.
I already showed my code to everyone after a contest (Fantastic bit), so I suppose this question has already its answer.
But I don’t code this way because I want to show my code. I code it this way because this is how I code
You must have time to think about your bot. And this is far different than “you must have time to code your bot”.