Tagged: C++ Toggle Comment Threads | Keyboard Shortcuts

  • fala13 13:56 on 17/06/2018 Permalink | Reply
    Tags: C++, Codingame, , , ,   

    CODE OF KUTULU @ Codingame 

    Why play games when you can write bots to play them? Join me at: https://www.codingame.com/contests/code-of-kutulu

    Once again I’m taking part in CodinGame online contest, this time in Lovecraftian theme ending on June 25. You implement a bot that is supposed to play in game run on Codingame site against other bots. The game is about explorers trying to survive the longest in a dungeon before losing their sanity.

    I already did get to silver leagues in other games like Ghost in the Cell (while refreshing my C++), Code Royale (Dota-like game, worked on my Python3 skills). In Code Royale I played with strategy pattern, so that I could easily change the behavior of bot and started using this lisp-like predicate construct to help me pipe a lot of conditions easily and read-ably:

    def dt(cond, l, r):
        x = cond is True
        print(str(x), file=sys.stderr)
        if x:
            return l
            return r

    This time I also want to setup my deck to be able to run games offline for faster feedback and potentially play with some better algorithms.

    Best players create simulations of the game, often re-implementing it for performance reasons. Being able to simulate the progress of the game they apply Mini-maxes, Genetic Algorithms, Neural Networks and other fancy things to select the best moves. This is in line with what Elon Musks OpenAI owning Dota2 single-player is about:

    edit: nice deep dive into properly approaching this kind of contests: https://github.com/Manwe56/competitive-programming/blob/master/docs/advices.pdf
    edit2: This post comes down to two songs by same guy:

  • fala13 17:59 on 02/06/2014 Permalink | Reply
    Tags: C++, compilation, gcc,   

    Bad performance after switching to C++11?! 

    Recently tool chain in my company (which is called Nokia now – awesome, right?) was update from GCC 4.2 to GCC 4.7. Everybody in my project was very excited – our software will be faster thanks to the move concept and just from standing next to the new compiler! And developers will be able to write lambdas that no one else will be able to decode!

    When first performance test results came in I was puzzled – improvement was expected and we got 5-10% performance decrease? I had to ask my overly enthusiastic developers to wait with enriching their code with new shenanigans and I’ve put my detective hat on.
    I’ve discovered that the new compiler is not to blame, only adding -std=c++11 makes the difference and shortly after Stackoverflow came with help: http://stackoverflow.com/questions/20977741/stdvector-performance-regression-when-enabling-c11
    Sufficient to say, default settings of GCC don’t trigger proper inlining of container methods of the STL’s C++11 version. When we increased the -finline-limit the performance got back to level without the -std=c++11 flag. But not a bit higher.

    Background: Our project does lot of message handling, uses STL quite heavily and is around 1 milion LOC. We get best results with -O2, yes, even better than with -O3. I have tested various flag combinations and nothing matches regular -O2. But that is for our application and our fast path use pattern. For yours you should always test, test and test for yourself (and investigate!).

  • fala13 06:05 on 03/07/2013 Permalink | Reply
    Tags: C++, ,   

    The Prize 

    WP_001278 (2)Every year I try to participate in the main polish programming contest Potyczki Algorytmiczne. It takes 1 week during which you are completely detached from your life and family. Since the level is quite high only it is impossible to get to the top 20 which takes part in the finale for people who don’t participate in such events on regular basis. So why waste a week every year?

    It is just like running in marathons. You run (I don’t, but it makes for a nice metaphor) to stay healthy, to show that you can endure the distance, to prove something to yourself. To have an achievement of some kind. And the same goes for programming contests like this. You want your brain to stay sharp, to still be proficient with the things you learned during your studies, to prove to yourself that you can tackle problems ordinary people can not. And you train C++ STL usage heavily which is good for your regular job. Luckily the PA contest gives T-shirts to first 256 contestants (there is about 1000 people participating each year) so you have some souvenir for your struggles.

    This year there were some cool problems, many dealing with primality testing. I made and environment consisting of UT, acceptance tests and gprof (total overkill) to ensure I don’t loose any points easily. You don’t want to loose your weekend for nothing!

    (Phew, it was hard to make this post about something else than bragging about having the 2013 t-shirt finally delivered.)

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc