C++ support

Is anyone building a bot for c++? I would like to take part, but I don’t think I would be able to build my own sample bot, and the only language I know is c++.

Why not give it a try in c#? C# is much easier than C++ afterall and you dont need to know anything fancy either; the included sample bot contains everything you need and Visual Studio (and MonoDev) provides great intellisense so, if you know how to code you really won’t have a problem at all.

Or alternatively, if you are really lazy then use the sample bot to call your c++ functions as via unmanaged code/dll. :slight_smile:

I’d also like to use C++ also.

Last year there was a Sample Bot for it.

Are we allowed to use C++ (will the game engine build our code?)?

If we do, do we need to use JNI or can we have our executable called directly?

It definitely sounds like C++ is supported: it is mentioned on the readme page on Github, and throughout the code (search for “CPlusPlus”).

My bot is in C++ and is working fine, though I did have to patch the Game Engine slightly to run the Linux executable directly, since I didn’t want to have to switch to Windows to compile it each time. But the msvc++ compiler is included in Visual Studio, so there shouldn’t be a problem there either.

Actually, looking through the code, I see this: C++ is not supported (No sample bot submitted)

@Wackymax, could we have C++ support please? I, and probably others, have written a virtually complete bot in C++, which I was certain was supported, based on it being one of the languages listed on the main Github readme page.

I am happy to write you a C++ sample bot (if you will let me know what it needs to do!)

I did a C++ bot last year. Simply submit it as a Visual Studio (C#) solution and everything should hopefully work. Maybe test is before you go any further.

Hi Malman,

We removed the C++ support because no one submitted a sample bot for it.

Technically the sample bot submissions have already closed. But because of the confusion and the fact that you already wrote a complete bot for it I will allow you to submit a pull request for a C++ sample bot. The instructions for the sample bot can be found on the Sample Bot read me on the Github page.

Thanks Wackymax. I think I did see the section in the readme about submitting sample bots, but I assumed that was to add support for a language not already in the supported list.

Anyway, here’s the pull request: https://github.com/EntelectChallenge/2017-Battleships/pull/44

It follows the C# bot in that I’ve included its packages in the pull request.

Apologies if there’s anything wrong with the VS config files - I think I got it right, and it compiles from scratch in VS, but I normally use Linux so I might have made some kind of mistake.

Thank you Malman,

The merge request has been excepted. I will update the game engine and tournament server as soon as possible to allow for the submissions and to run the calibration bot.

hehe, @BoerBedonnered is suggesting @lazi might be lazy :stuck_out_tongue:

Ok I’m a bit lost here

I have a c++ bot and it works with the game engine when I run it.
It’s all very simple, basically just a main.cpp file

When I upload it to the portal it complains a lot. How do I get this to work?

Hi All,

Game engine and player portal has been updated to allow for C++ submissions. Please check if everything is working correctly now.

Still not working for me.

My zip has a readme a bot.json a compiled exe and a source folder with a main.cpp

I also tried to upload the sample bot with the source of the sample bot changed to my main but still no sucess.

Hi linjoehan,

I had a look at your upload files. Your zip file must contain all of the source files so that we can compile your bot on the tournament server. Unfortunately it has to be a visual studio project in order for the compilation to work on the tournament server. In your bot.json file you must point the ProjectLocation to the solution/project file that will compile your bot and the the 'RunFile` will be the final exe that was created from the compilation step.

Sigh. is there no template I can just put it into? I really don’t want to have to find VS just for this. It’s over 10 GB to download

Hi Linjoehan,

You can maybe try to alter the source files using the sample bot:

Just make sure to update the project file with any additional files you add.

Linjoehan, just modify the source code as Wackymax said…to upload it you do not need a compiled version of your code (you can use the portal to test whether it actually compiles at all). So, you dont need VS per se.

Yay it works

Maybe just a note which took me some time to fix is that the compiler doesn’t know ‘and’ and ‘or’ I had to use && and ||

Anyway thanks for the help.


Am I the only one who didn’t know “and” was a valid C++ keyword?

Turns out it is: see here for anyone else who’s interested.

Unsure how I knew about digraphs and trigraphs (which are used so infrequently these days that they are pretty much just curiosities) as alternative tokens but not about “and”!?

And since it is a valid keyword, I wonder why msvc doesn’t have it!

I didn’t know.

Do you know which revision of the language spec it was added in?