- Created Friday, November 28th 2014 @ 21:34:17
I found my way into the game by taking the C++ Starter bot and improving its code style. What i did is:
- cleaned up the includes
- fixed initialization bugs
- added const-correctness
- sorted the includes more cleanly
- replaced the c-ish unsigned with c++-like size_t definitions
- fixed the mixed tab and whitespace intendation
- reordered the class function and inserted meaningful spaces
- added exception handling in the run to allow for c++ exceptions
- removed using name std: declarations from headr file as they can cause subtle bugs
- replaced that game action magic string with a clear enum
- simplified the string split function
- removed confusing C-style debug outputs
- made comments doxygen style and added some more escpeciallys at the functions the user needs first
- inlined trivial getters and setters
- added a build file (qmake) which allows local build with similar settings
- removed underscore and CamelCase mixins
The behaviour of the bot did not change, and i did not add any game mechanics as this is intended as a starting point. Although some of the changes are a matter of taste, a lot of them improve c++ code style and a few of them even fix hazardous bugs fresh players do not want get frustrated with. I also intended not to change the required C++ skill level to understand the code.
The updated version can be found here: https://github.com/pizzard/warlight-starterbot
Depending on the feedback here I am thinking on continuative improvements, there if still a fair bit which could be done.
- Created Wednesday, December 3rd 2014 @ 08:38:18
Which hazardous bugs are you referring to? I've been using the C++ starter and haven't noticed any significant bugs.
DeveloperCreated Thursday, December 4th 2014 @ 09:12:43
Nicely done, code looks good. :) But I don't think I will change the current starterbot for this competition, but very soon the next Warlight AI Challenge will be released. The starter bots will be pretty similar, except for a few small changes. I'd like to have your C++ then available if you could implement these changes once the competition is live.
Also adding some comments to your code would be nice.
- Updated Sunday, December 7th 2014 @ 16:46:58
Regarding the hazards:
- untintialized values depending on usage lead to unexpeted behaviour
- Game class could possibly stay untinitalized when you change the calling code which would lead to segfault
- std namespace declarations may ruin your day when using abs and clutter your namespace
and few unclear interfaces that could possibly be misused.
All these things indeed unlikely to happen and with some experience you may not have ran into them yet, but they can ruin your day if you do so, as friend of mine once did :)
I'm looking forward to do some refactoring of the parser and the overall structure (and continuing this), and I surely can update it when a new version is out.
It would be very cool to at least have the boost headers available on the server, and some compiled modules would be awesome too. Would create cleaner code in some places.
Regarding the comments: I still haven't completely figured out the intention of all the so far uncommented methods out there, but as soon i get into it I can add that. I already added a bunch of comments.
- Updated Monday, December 22nd 2014 @ 19:13:53
The thing i am going to look at first is the while loops in the region and super region add functions.
Yes they do "work" as such but they add a suprious element index 0 which is empty. It does have the efect of 1 index the array's which is ok but it's a side effect to be honest but i do like what you have done over-all, expect a pull request from me shortly.
it means my iterators were all confused when using the first element.
- Updated Monday, December 22nd 2014 @ 19:20:14
@jim kevle has made a pull request i recently merged where he updated the starter bot to the new warlight challenge. also he added some random movement logic. Thanks for kevle!
As soon I got some spare time i will continue the overhaul, also including more documentation. It would be really nice to have boost in the server, then i could handily improve the parser and clean up some more.