Hello
I would like to use C++ for my algorithm, but in the git StarterKit repository, there are only Python, Rust and Java.
Is it possible? If yes how to do it?
Thanks!
Hello
I would like to use C++ for my algorithm, but in the git StarterKit repository, there are only Python, Rust and Java.
Is it possible? If yes how to do it?
Thanks!
I’m not really sure how to do this myself, I know people like arnby are using it.
Check out this thread maybe?
Only Python, Rust and Java are normally supported.
However many top players (including myself) use “tricks” to use C or C++ for performances.
You should be aware that those tricks could stop working at any time with a game update:
That being said in the thread @IWannaWin linked, I explain my way for using compiled C++ subprogram in Python.
Another way to use C++ is by compiling a python extension. This directly interfaces with Python so (personally) I believe that it should always work since you import it just like a normal python module. As far as I have found there isn’t a ton of unofficial documentation about it so you probably need to be comfortable implementing code primarily only using the Python documentation (which is quite good) since there aren’t many tutorials about how to do it.
It should be noted that I do plan on writing a little intro about this soon (I have been quite busy as of late) since I think it’s a valuable and interesting skill people would benefit from learning how to use.
If you are interested in doing this I suggest reading into shared object (SO) files and into the ctypes python module.
To clarify:
You can use the ctypes module to import SO files. In these you can basically export c-type functions for python to use. In python you will just have to define the interface and you’re ready to go. One advantage is that you dont need to compile anything on the server, but can do all on your PC before uploading (at least if you are working on linux, not sure if its the same for shared object files for windows).
If you are interested in that approach (or anyone else is interested), I can maybe write a tutorial (if the people from c1games dont have any problems with that) or pm you a basic example to work with.
As I said once in a different thread, if you are having performance problems, Rust is just as fast as C++, officially supported, and you won’t even get segfaults. You’ll have to learn it, of course, but this is a great time to do that, and Rust is a nice language to have in your arsenal.
I used the same method as @Zaustie to put a simulator on C++. You do have to port over a lot of the gamelib folder, which kinda sucks (and hurts your arm to type so many { } 's and ; 's).
This guide was fantastic and told me 95% of what to do. This tells you how to create a C++ class that you can use to call methods, but AFAIK those methods need to return primitives (or at least an array of primitives). Haven’t had any success on returning objects, but there’s always hacky workarounds to get what you want.