Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Setting flag versus matching exact conditions
Setting flag versus matching exact conditions
May 12 2014, 12:38 am
By: sethmachine  

May 12 2014, 12:38 am sethmachine Post #1



Hi,

I think the title is vague (apologies, didn't know what to call this).

Consider this case where, once determined, the value of some predicate P (true or false) is set permanently. In our case predicates are some chains of conjunctions/disjunctions of Starcraft conditions.

In any case, is it more efficient to:

1. Have a single trigger that detects P's value, then stores this in a boolean variable.

2. Triggers which need to know P's valuation now reference this boolean instead of testing all of P's valuations.

Or

1. Triggers which need to know P's valuations always test them as part of their conditions.

I am figuring that the former case is probably more efficient, but in any case, is it the norm for SC mapmaking (or coding in general)?



None.

May 12 2014, 12:49 am Roy Post #2

An artist's depiction of an Extended Unit Death

You're thinking on an efficiency level that doesn't matter for most maps, so if performance isn't an issue, I wouldn't bother increasing the complexity of your triggers.

That being said, checking the value of a switch / death counter is much more efficient than checking certain conditions, such as the Bring condition (which is notorious for causing performance issues on large-scale maps).

It's always wise to order your conditions so that switches come first, followed by simple numerical comparisons (like death counters or accumulated resources), followed by the other, more complicated conditions.

For coding in general, your suggestion is a form of caching or maintaining state, where computing a result once and storing it can be much more efficient than computing the value repetitively. However, for a lot of higher-level languages, this is unnecessary, as the compiler will optimize it for you (e.g., you can say "1000 * 60 * 60 * 5" as means of calculating 5 hours from milliseconds, and the compiler will convert this to a constant value rather than do the multiplication every time).




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[01:24 pm]
Vrael -- NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
[2024-4-30. : 5:08 pm]
Oh_Man -- https://youtu.be/lGxUOgfmUCQ
[2024-4-30. : 7:43 am]
NudeRaider -- Vrael
Vrael shouted: if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
Yeah I'm not a big fan of Westernhagen either, Fanta vier much better! But they didn't drop the lyrics that fit the situation. Farty: Ich bin wieder hier; nobody: in meinem Revier; Me: war nie wirklich weg
[2024-4-29. : 6:36 pm]
RIVE -- Nah, I'm still on Orange Box.
[2024-4-29. : 4:36 pm]
Oh_Man -- anyone play Outside the Box yet? it was a fun time
[2024-4-29. : 12:52 pm]
Vrael -- if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
[2024-4-29. : 11:17 am]
Zycorax -- :wob:
[2024-4-27. : 9:38 pm]
NudeRaider -- Ultraviolet
Ultraviolet shouted: NudeRaider sing it brother
trust me, you don't wanna hear that. I defer that to the pros.
[2024-4-27. : 7:56 pm]
Ultraviolet -- NudeRaider
NudeRaider shouted: "War nie wirklich weg" 🎵
sing it brother
[2024-4-27. : 6:24 pm]
NudeRaider -- "War nie wirklich weg" 🎵
Please log in to shout.


Members Online: Roy