As someone who just found this competition and would like to join, what language would you recommend for me to use? It seems like all the top players are using Python, although I thought Java was faster which seems pretty important for a competition like this. Is there a reason everyone is using Python over Java?
Python was the first language supported, so most of us just stuck with it. There are also some methods for getting C++ interfaced back into Python, although rumor has it Rust is just as fast.
Personally I have C++ do all my dirty work and let Python handle all my high level logic, although it hasn’t been “necessary” to do so. It’s perfectly possible to stay within the time constraint (5 seconds per turn) while using Python.
That makes sense. Any chance you could link me some resources/examples of how to get the python code to interface with C++?
Well you can find some in this forum, for example:
(scroll down a bit)
Personally I only use python though, so I can’t really show you how to do this.
Whoops! I grabbed the link but never added it in. Edited. Personally I use this method.
I got started back when Python was the only option and was able to hold the global #1 for a period of time. My algo back then was only slightly dynamic and used the built-in pathfinding along with some of my own action phase analysis. But I had no true action phase simulator and would hit >1000ms processing time even with my rudimentary approach. (I’m sure a lot of this was due to my limited understanding of optimizing python code)
@kkroep is proof that a deep understanding of Terminal and clever innovation can be very successful without needing a highly dynamic algo, but he’ll even admit that the lifetime of his innovations are only so long as people figure out weaknesses. As the level of play keeps rising, I’m convinced that long term success in the global competition will require a very adaptable aglo.
So after I needed to step away from Terminal for a time, I decided to start completely from scratch and gave Rust a try. I had never even heard of Rust prior to working on my new algo, but I had a ton of fun learning and was set on building a full* action phase simulator (for some definition of full) before even worrying about making my algo do anything interesting.
And the performance difference is huge!
I haven’t added precise timing calculations yet, but based on global leaderboard matches I can run a full action phase simulation with a stack of a single unit type (including any potential encryption) in around 1-2ms.
I briefly considered putting together a hybrid Python/C++ algo, but in the end I’m glad I took the time to learn Rust.
I also started back when Python was the only option, and @Ryan_Draves is correct that I’m primarily using it because I have already written a bunch of code for it. I would be more likely to make a switch if C++ was supported, simply because I have written a bunch of code using C++ and Python together. If you are interested in this method I wrote a tutorial style post that @Ryan_Draves linked, but this is mostly for educational purposes or for people who really don’t want to leave Python and already have C++ experience.
If I was starting today, I would go with Java if you’re familiar with it. If not, then Rust or Java.
An important question to ask yourself is what do you need the speed for? Typically, Python’s advantage is it’s speed and ease when developing. The tradeoff is faster development time vs execution speed (generally). Often when developing, I’ll simply “get it done” in Python, and then run time tests. You can then replace what is slow with C++. This, of course, only works if you do it the way I have (I am also biased towards python and c++ since I know them best), and have the experience to do so. So to reiterate, the best option now would probably just be Java or Rust.