Menu

Optimisation and new features

2015-09-11
2015-11-12
  • Diggi Doggi

    Diggi Doggi - 2015-09-11

    Hi guys, nice to see you alive :)

    Because of this application not getting any updates (apart from mods) I decided to dig in a bit. And just share my findings. (Don't take me wrong, it's really good app already, but good can always be better).

    First feature that I was missing was ability to make a screenshot of the whole world. It looks amazing when you watch at it from 'distance', it's like a galaxy and gives you clear view on how those bacterias organise... So, I've done the screenshot ability which was very simple with your clear source code.

    Other thing. On my not-so-fast computer I can simulate quite huge worlds, like 10,000x10,000 size with initial 10,000 microorganisms with CO2 at level of 1,000,000 (yes 1 million) however it's not so fast. I have checked the source code and see that some things are repeated, for example:
    1) does A intersect B, if yes update both
    2) does B intersects A, if yes... update both
    Of course it's not that straight forward but it is there and it's executed with every iteration. So, to avoid doubled calculations (intersection and bounce consume lot of time and CPU) I propose to use an array property where you store information of which organisms have checked collisions with this particular organism.

    If organism A find that it's intersecting with B, it processes it the 'old' way with 3 exceptions:
    1) Updates B array of processed connections ('I was here')
    2) Updates x, y position and the angle theta of organism B (it calculates it anyway in your version,and it's enough to negate 1 vector instead of calculating all that again in B)
    3) B, like every other organism, checks it's connection to other organisms by iteration through all of them. Thanks to the array of it's visitors it knows that calculations are already done and ... simply skip to C without recalculating A.

    I have checked that on 5,000x5,000 world with average 8,000 organisms and the result is 30% speed increase.
    Downside? Yes, there's always some. It consumes more memory. I use array of 16 processed connections which doesn't result in high memory consumption (less that 1GB for avg 10,000 organisms vs 200-300kB without it), however for small and very packed worlds the amount of intersections may exceed 16 connections. When the number of intersecting organism is greater than 16 the old method is seamlesly used for 16+, so still you gain some speed increase.
    I'm still upgrading it but it's not an easy task to process a couple of thousands vectors efficiently. I though of rigid bodies, but then we need info about which section intersected what anyway. Maybe you have some better ideas.

    As about the translation... Adding new language requires updating the source code in 'messages' module also updating the rest of language files to add the new one. That makes the job less pleasant. I haven't touch that yet as I don't really mind, but it could be made more human-friendly ;) Anyway I've done my translation to Polish language, also corrected typos and not-so-clear wording in English should you wish to add this to the project.
    Also, what you think if translating the language name is abandoned? Just display the language name in that language. In Polish, for instance, you'd look for Polski instead of something you don't understand like 'Polish'. Imagine, you switched to Turkish just to see how it's looking like and can't get back to Spanish just because it is displayed as 'ispanyolca'.

    I really love this app and appreciate your work you've done, maybe I sound harsh in my post but I really think this app can be even better. Posibly separating data and logic layer from rendering (_VisibleWorld) could lead to openGL implementation which could speed up vector processing. And openGL could allow us to display small viewport with 3D models... but that's just my phantasy.

    I hope you like my ideas, if you're interested in source code just shout, there re few more updates inside. I'll not publish my modifications on my own as it was your idea to make the amazing app.

    Kind Regards
    Diggi Doggi

     

    Last edit: Diggi Doggi 2015-09-11
  • cliftut

    cliftut - 2015-09-13

    Well I'm just a newbie so I can't speak for others, but I welcome performance improvements, and I don't think you sounded harsh at all! ;) Given that there is a memory trade off, it might be nice if the user could choose in the options whether to calculate the new or old way, or even set a memory limit? I don't know the difficulty of such things.

    Regarding OpenGL, isn't this already implemented under World>Parameters>General? It's been a while since I used the program previously so I have forgotten whether it worked for me in the past.

    To my uninformed ears all of your suggestions sound good, we'll see what others say. Granted that there are other mods of the code hanging around (the Color Mod and Tyler's Feature Mod - inluded in Color Mod 1.4), further mods are probably welcome.

     
  • AlexL

    AlexL - 2015-09-23

    Hi Diggi,
    Where are your modifications? Will you provide a url?

     
  • Richard David Williams

    I'd be happy to dig in and look at your modifications as well!

    Which branch did you start off of? I have recently been thinking about how we could speed up the performance of the program as well.

     

Log in to post a comment.