embeded elseifs or just ifs
beaudoin_n
Member Posts: 184
Hi,
Has anybody experimented of the advantages of using otherwise versus simply stating another rule
Example
rule if attribute a = 1
behavior
otherwise
rule if attribute a =2
behavior
otherwise
...
or simply rule1 if attribute a =1
behavior
rule 2 if attribute a = 2
behavior
How is performance affected ?
Are there known issues
Cases were it might cause bugs ?
Thanks
Has anybody experimented of the advantages of using otherwise versus simply stating another rule
Example
rule if attribute a = 1
behavior
otherwise
rule if attribute a =2
behavior
otherwise
...
or simply rule1 if attribute a =1
behavior
rule 2 if attribute a = 2
behavior
How is performance affected ?
Are there known issues
Cases were it might cause bugs ?
Thanks
Comments
You want the processor to check as few conditions as possible.
So in your second scenario, if your attribute IS 1, the second Rule still has to be checked, wasting resources.
Ok now i wish for a case function
I have this positionning done on one of 5 spots
and i check if i am not in any i try to find the first available.
Somehow i got it all messed up
It has a first rule that states (if out of bounds)
then i had embedded ifs to check if the first spot value is false
then otherwise if second spot is false
etc...
So looks like i have to keep the otherwise statements... i also had a mini timer but now it seems that with more objects on the screen it starts behaving weird
is the speed of the timer in any way affected by the overall performance ?
Example:
If myMainSwitchingAttribute = True
then... (run to completion checked)
-- myMainSwitchingAttribute = False
-- myOtherTrailingAttributes are still executed (even though the function rule is no longer valid)
If myMainSwitchingAttribute = True
then... (run to completion is NOT checked)
-- myMainSwitchingAttribute = False
-- myOtherTrailingAttributes are NOT executed and are ignored (because the mainSwitchingAttribute was changed and the function is no longer valid)
Clean and efficient rule structures are key to optimizing performance.
Rule
When Touch is Pressed
Timer
After 3 seconds
Change Attribute self.hasbeenPressed To TRUE
Rule
When Touch is Pressed
Timer
After 3 seconds Run To Completion
Change Attribute self.hasbeenPressed To TRUE
In the first scenario, if I remove my finger from the button before 3 seconds, the Timer will not fire.
Whereas it will in the second scenario...