User Tag List

Results 1 to 8 of 8

Thread: Too many conditions in events: solutions?

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module

    Join Date
    Dec 2008
    Location
    Italy
    Posts
    404
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)

    Post Too many conditions in events: solutions?

    Hi,
    I'm developing the platform engine for my game.
    I'm expanding the engine, so the code is becoming more and more complex. I often find many conditions within the same events, like in the example below.

    conditions.png

    Does such volume of conditions (in the same event) impact on the speed of the application? Many events in my application are structured this way.

    If so, could grouping conditions be a possible solution to reduce the number of conditions? i.e. in the example screenshot, I could create another event which says that when GrabberUP = 0 + GrabberLEFT = 0 + GrabberRIGHT = 0 => GrabberGLOBAL = 1
    Then I replace all three conditions with the last, global one GrabberGLOBAL = 1. Does it have sense?

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module

    Join Date
    Dec 2008
    Location
    Italy
    Posts
    404
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Hi, sorry if I bump this thread, does anyone have any idea? I would like to optimize the code of my application, any suggestions are welcome...

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Aug 2011
    Posts
    145
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry i dont know the answer but i would like to hear from someone about this very topic too.

  4. #4
    Clickteam Clickteam
    Simon's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    2,647
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    If you had a large number of events which did the exact same set of tests for those grabber direction alts, adding them first and storing in an alt could be slightly more efficient, but I'm thinking of 100s or 1000s of looped events here. If it's just a couple I don't think it's necessary at all.

  5. #5
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,731
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    This is a near quote by one of the founders of Clickteam. The number of events has absolutely no effect to the speed of a program.

    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    UltimateWalrus's Avatar
    Join Date
    Jul 2006
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Remember, premature optimization is the root of all evil. You shouldn't be trying to optimize your code unless you absolutely know speed will be a problem. Try to write clean, understandable, and maintainable code and worry about optimization later if it's necessary, and if it's not, great!! You don't have to waste time on it.

    The events in MMF are short-circuit evaluated. This means that it goes from the top down, and as soon as it finds one condition that's false, it stops wasting processing power and exits the event. For this reason, if you need to optimize, you can put the most unlikely conditions at the top, which means it will stop evaluating on the first few conditions most of the time. It doesn't matter if you have a lot of conditions in one event.

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module

    Join Date
    Dec 2008
    Location
    Italy
    Posts
    404
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Precious information, thank you all

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    UltimateWalrus's Avatar
    Join Date
    Jul 2006
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to add one thing: not all conditions hold the same amount of overhead. So for example, "Object A is overlapping Object B" likely taxes the CPU more than "Object A Flag 0 is on". So, when optimizing certain events, you might find it beneficial to put less-taxing conditions higher up; this not only prevents the more taxing conditions from running more often, but when they do, they may benefit from having the selection narrowed down. Example:

    Object A is overlapping Object B
    + Object A Flag 0 is on
    (this means mmf must test all Object A against all Object B, then worry about flag 0)


    Object A Flag 0 is on
    + Object A is overlapping Object B
    (from having developed extensions i'm fairly sure that this gets optimized. so mmf will only test Object A's that have their flag 0 on, against all Objects B's, which could be a much lighter operation)


    EDIT: One last note: If your conditions start with a "true event" (the green or red colored conditions), then it won't even be checked at all until the event occurs, which is nice.

Similar Threads

  1. What events or conditions are heavy on memory
    By Simflare in forum Fusion 2.5
    Replies: 8
    Last Post: 19th August 2014, 09:28 AM
  2. $25 for the correct solutions
    By Perry in forum Fusion 2.5
    Replies: 14
    Last Post: 15th April 2014, 03:42 PM
  3. Too many conditions/ORs in an event vs separated events
    By DinnerSonic in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 26th July 2012, 04:14 AM
  4. disable/deactivate certain conditions/events?
    By murderdeathkill in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 5th January 2008, 06:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •