Staredit Network > Forums > SC1 UMS Theory and Ideas > Topic: Condition Ordering
Condition Ordering
Dec 1 2009, 5:29 am
By: ClansAreForGays  

Dec 1 2009, 5:29 am ClansAreForGays Post #1



So I just remembered something back in one of my C# programming classes. When making multiple conditions (&&) for your IF statements, it's best to put the least likely to be true condition first, because if it is found false, it's smart enough to not even bother finishing the IF statement to see if the other conditions are true, thus saving time/cpu.

I was wondering if something as primitive as triggers follow the same principle? Like If I have a trigger with 2 conditions, and one is "commands 1 firebat"(which is almost always) and the second is "Has suffered exactly 33 deaths of zergling"(which is almost never). If I reverse the order, then most of the time only 1 condition will be checked every trigger cycle, instead of 2.

Do you think sc is this efficient? Heinnerman is probably the only person who could answer this. If not, I have an awkward idea for a test map, and it would be nice to have discovered something new (How to Shave-Off Map Lag) that I can credit to myself.




Dec 1 2009, 5:34 am scwizard Post #2



Pretty sure triggers work the same way. I have no evidence though, just assuming they do since the triggers are translated into code, and code works that way.

I always put switch conditions that are more likely than not false as the first condition if I can.



None.

Dec 1 2009, 5:40 am Falkoner Post #3



This was discussed a while back, yes, placing the least likely to be true condition first will use less processing power than having to run through several true conditions before discovering the entire thing to be false.



None.

Dec 1 2009, 5:46 am ClansAreForGays Post #4



Cool. I'm glad I haven't been wasting my time being a freak about those little things.

How was it proven?

Also, this need to be added to this under "Map Lag" The fact that it actually wasn't mentioned there was the biggest reason I thought this hadn't been decided on yet.




Dec 1 2009, 5:59 am Kaias Post #5



Falkoner is correct. It stops checking the conditions once one of them returns false. While it doesn't make a real difference in maps with medium and lower amounts of triggers, it is absolutely crucial when you are, for instance, at 15k.

Most likely to return false shouldn't be the only factor, however. The bring condition has much more work attached to it than reading, for example, a binary switch, which is why I always put switches at the top of the list.



None.

Dec 1 2009, 6:00 am Vrael Post #6



Will do. It wasn't there because I can't empty 100% of my mapmaking knowledge all at one time :D



None.

Dec 1 2009, 10:57 pm samsizzle Post #7



wow this is gonna be great.



None.

Dec 1 2009, 11:04 pm Cinolt Post #8



This can be proven through changing the order of a crashing EUD condition, I found this out inadvertently.



None.

Dec 1 2009, 11:10 pm rockz Post #9

ᴄʜᴇᴇsᴇ ɪᴛ!

Now we need Heinermann and Farty's compressor to organize conditions in the best order. It would be interesting to see how much, if at all, it lags. (15 bring conditions with 1 switch at bottom, times 15k).



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Dec 1 2009, 11:23 pm Cinolt Post #10



Quote from Kaias
While it doesn't make a real difference in maps with medium and lower amounts of triggers, it is absolutely crucial when you are, for instance, at 15k.

My map's at 17k with its share of bring conditions but there's never any lag that's the map's fault. It has no give actions whatsoever, but we're talking about difference in condition ordering/checking, so I wouldn't worry too much about it.

I thought lines, where does it tell you trigger count in SCMDraft2 anyway?

Post has been edited 2 time(s), last time on Dec 2 2009, 1:14 am by yoonkwun.



None.

Dec 2 2009, 12:51 am O)FaRTy1billion[MM] Post #11

👻 👾 👽 💪

Quote from rockz
Now we need Heinermann and Farty's compressor to organize conditions in the best order. It would be interesting to see how much, if at all, it lags. (15 bring conditions with 1 switch at bottom, times 15k).
What does that have to do with compression?

And I can further confirm this based on my experiences...



TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB - topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig - topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Dec 2 2009, 1:04 am Morphling Post #12



Quote from rockz
It would be interesting to see how much, if at all, it lags. (15 bring conditions with 1 switch at bottom, times 15k).
Here. 20,000 triggers plus four hyper triggers.

Attachments:
Condition Order Lag.scx
Hits: 1 Size: 731.46kb



None.

Dec 2 2009, 1:44 am Norm Post #13



Hm, so if the map is expected to be ~500k, would it be worth it to reorganize conditions to reduce lag?



None.

Dec 2 2009, 1:45 am Morphling Post #14



What kind of map are you making...



None.

Dec 2 2009, 1:47 am Norm Post #15



Quote from Morphling
What kind of map are you making...

HS.



None.

Dec 2 2009, 1:48 am Morphling Post #16



What exactly are you doing that takes that many triggers?



None.

Dec 2 2009, 1:49 am Norm Post #17



Quote from Morphling
What exactly are you doing that takes that many triggers?

I dunno, things just add up ><. It's a pretty complex map.

It doesn't matter though, will I notice a difference reorganizing 500kb worth of triggers?



None.

Dec 2 2009, 1:50 am Kaias Post #18



Quote from Norm
Hm, so if the map is expected to be ~500k, would it be worth it to reorganize conditions to reduce lag?
Unless you're using EUD/EPDs there is no reason for it to get that high. But to answer your question, yes, it would be worth it.

Edit: Loool. 500kb worth is much much different than 500,000 triggers.



None.

Dec 2 2009, 1:53 am Morphling Post #19



Quote from Norm
Quote from Morphling
What exactly are you doing that takes that many triggers?

I dunno, things just add up ><. It's a pretty complex map.

It doesn't matter though, will I notice a difference reorganizing 500kb worth of triggers?
It's only 500kb? That's a long ways away from 500,000 triggers. Triggers on my map I posted had only 20,004 triggers and is less than 800kb



None.

Dec 2 2009, 1:55 am Norm Post #20



Quote from Kaias
Quote from Norm
Hm, so if the map is expected to be ~500k, would it be worth it to reorganize conditions to reduce lag?
Unless you're using EUD/EPDs there is no reason for it to get that high. But to answer your question, yes, it would be worth it.

Edit: Loool. 500kb worth is much much different than 500,000 triggers.

Ehhh, I never meant you guys to think I was making 500,000 triggers lol. Indeed the map is going to be 500kb on completion - it is ~450 now and I should definitely reorganize them? Alright I have some prime suspects for reorganization needing.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[03:55 pm]
Zoan -- :wob:
[10:34 am]
NudeRaider -- SEN doesn't rely on spammers initiate its sleep cycle. It hat fully automated rest and clean-up phases. Please understand that this is necessary for the smooth operation of the site. Thank you.
[03:45 am]
Sylph-Of-Space -- Does the shoutbox get disabled when there's spammers?
[2024-5-17. : 6:47 am]
NudeRaider -- lil-Inferno
lil-Inferno shouted: nah
strong
[2024-5-17. : 5:41 am]
Ultraviolet -- 🤔 so inf is in you?
[2024-5-17. : 4:57 am]
O)FaRTy1billion[MM] -- my name is mud
[2024-5-17. : 4:35 am]
Ultraviolet -- mud, meet my friend, the stick
[2024-5-16. : 10:07 pm]
lil-Inferno -- nah
[2024-5-16. : 8:36 pm]
Ultraviolet -- Inf, we've got a job for you. ASUS has been very naughty and we need our lil guy to go do their mom's to teach them if they fuck around, they gon' find out
[2024-5-16. : 5:25 pm]
NudeRaider -- there he is, right on time! Go UV! :D
Please log in to shout.


Members Online: newageofpower, 8milae9823tp0, Roy, 3milae7523gc6, 1jasminec193hL4