Performance Optimization Question

Asobu_GamesAsobu_Games PRO Posts: 261
edited April 2012 in Working with GS (Mac)
This might be an obvious (or very stupid) question, but am I right in thinking that you could optimize game performance by splitting your rules into groups of rules so that the system has less rules to check to get to the correct rule?

For example, lets say you have 100 rules based on an attribute (X) that could be between 1 and 100. (ie if X = 1 then... etc) Lets say in this case the attribute X = 5. You could get to the correct rule like this: If X is between 1-50 > If X is between 1-25 > If X is between 1-12 > If X is between 1-6 > If X = 5.

As far as I can tell, in the above example the system would be checking far fewer rules to get to the correct one. If you just made 100 separate rules it would have to check all 100 which I imagine would cost performance/memory. Does this make sense? I hope I explained it clearly.

Thanks! :)

Best Answer

  • MarkOnTheIronMarkOnTheIron Posts: 1,447
    Accepted Answer
    Another option is to use the otherwise section of a rule.

    If X = 1 do something
    otherwise
    --If X = 2 do something
    --otherwise
    ----If X = 3 do something
    ----otherwise

    That way if X is 5 it will stop running the rule at that point instead of checking all of them.

    You should try different methods and see which better fits in your game.


Sign In or Register to comment.