Compiling issues with Python and C++

Compiling issues with Python and C++
0

#1

I’m trying to build my algo with C++ called through Python. I’ve gotten my C++ to compile to a .so file that the Python is able to interface with fine and I can play games locally without an issue, but when I submit to the competition I get a compilation error and it tells me to submit a new algo.
My submission process looks like compiling the C++ locally, moving the resulting .so file into my algo folder and then zipping and submitting that. I’ve seen on here that others seem to be using this C++ .so method, could someone give me a recommendation on how to get this to compile on the competition servers?


#2

Are you getting any error messages, or does it fail at the “compile phase” of the upload? My best guess is you’re not compiling for a Linux environment. I’m surprised that the “compile phase” would fail because of the C++ - are you using sys.path in python to locate the .so file?

If it’s the “compile phase” that it’s failing, and you’re unable to any error messages, try excluding the .so file. Your algo will crash, presumably, but it should get past the compile phase and confirm that that file is the issue.


#3

Yeah turns out it was an issue with how I was submitting and it works, thanks!


#4

Also, as a tip for future bugs in the playground (not there will be any :D) you can download the replay file and then pass each line to algo_strategy (or whatever script for you handles communication with engine.jar). So instead of running the engine locally, you’d just run python3 algo_strategy.py and then pass each line in from the downloaded replay file until it gives the error. This has been quite useful for me when debugging difficult to track down errors in my C++ code.


#5

More on…compiling in Python


#6

There is a build in script for this: scripts/test_algo_[oc]

scripts\test_algo_windows.exe my_algo_path replays/some.replay

check the readme for more details:
https://github.com/correlation-one/C1GamesStarterKit/blob/master/scripts/README.md#testing-your-algo-locally


#7

Yes, this the solution now. When this post was made there weren’t any test scripts so my post above was the best I could do when I was building my simulator.