Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Conditions lag: Bring, Command and the rest
Conditions lag: Bring, Command and the rest
Aug 4 2013, 9:16 pm
By: Wormer  

Aug 4 2013, 9:16 pm Wormer Post #1



I didn't want to revive old threads, so here is a new one with the specific question. Then again, I know similar things been discussed several times before, but there is a particular question which I haven't got a satisfactory answer yet.

It's known conditions introduce lag to the map. Regarding lag, conditions fall into 2 groups: Bring-alike and Deaths-alike. Conditions of the first group populate cache with units, when the second group conditions mostly just check a value, or two, or up to around ten values in the worst case.

Group 1: Bring-alike conditions.
Bring, Command The Most At, Command The Least At.

Group 2: Deaths-alike conditions.
Never, Always, Switch, Accumulate, Least Resources, Most Resources, Deaths, Kills, Least Kills, Most Kills, Score, Highest Score, Lowest Score, Elapsed Time, Timer, Opponents.

As you've noticed there are 3 conditions I haven't put into any group, they are: Command, Command The Most, Command The Least. The question is where should I put them? Are they really closer to the second group than to the first one in terms of the amount of required processing power?

As far as I understand, somemost people suppose in this topic that Command conditions are almost as effective as Deaths. I have doubts, because Command still populates cache with units (pass one) and then it is going through cache couting occurencies of a unit or group of units (pass two). Of course pass one is simpler in comparance to Bring because units aren't checked for collision with location, but there are still two passes through a pretty large units array.

I'll try to make some numbers. Let's say an average map may include around 500 units, but I believe the first pass must be done over the whole units node array which has 1700 entries. That way there are roughly 2200 comparance/assignment operations for Command condtions. With Bring we have 4 comparance operations more (to check locations bounds) for each unit on the map on the first pass: we add 500*4 operations and get 4200 total.

So, I'm personally putting Command-alike conditions into the first group regarding the amount of processing power they take, but what can you say? Do you think they are really closer to Death-alike conditions than to Brings? I'm not familiar with low SC code myself, but I really want to know an opinion of people who know it well. Am I right with my assumptions and calculations? Probably I have missed something significant?

Relevant topics:
Map trigger lag?
Bring/Command Updating Discussion
Map lagging conditions.

Thanks for your attention!

Post has been edited 2 time(s), last time on Aug 4 2013, 9:23 pm by Wormer. Reason: Reformatted paragraphs and fixed typos



Some.

Aug 4 2013, 9:25 pm jjf28 Post #2

Cartography Artisan

Code
00582324     1.16.1     Win     All Unit Counts Table           4     2736    
00584DE4     1.16.1     Win     Completed Unit Counts Table     4     2736    


The reason I rank the non-location based command conditions near deaths is because they should be able to use numbers from these tables, which are well maintained, rather than having to check through all the units.



TheNitesWhoSay - Clan Aura - github

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Aug 4 2013, 9:30 pm Azrael Post #3



Brings is in its own league as far as potential lag is concerned. It does something more intensive, regarding memory allocation and physically scanning the map, which Commands doesn't do. This being the case, I believe saying Commands is "Bring-alike" would be extremely misleading.

Keep in mind that, while Brings is on another level, the other conditions still have varying levels of intensiveness. Commands would contribute more to lag than Switch, for example.

You'd need more classifications if you wanted to make it especially accurate, but even if you're just using two categories, Brings and Commands shouldn't be grouped together.




Aug 4 2013, 9:31 pm Wormer Post #4



I remember you told about memory leaks before. I was very suprised then. :) But you haven't been more specific than that.

I'm saying those 2 other conditions (Command The Most At, Command The Least At) are Bring-alike because they're also checking for each unit if it is on the location while populating cache.

I always believed that this location checking for each unit is the stumbling block of all brings.

EDIT:
Quote from jjf28
Code
00582324     1.16.1     Win     All Unit Counts Table           4     2736    
00584DE4     1.16.1     Win     Completed Unit Counts Table     4     2736    


The reason I rank the non-location based command conditions near deaths is because they should be able to use numbers from these tables, which are well maintained, rather than having to check through all the units.
jjf28, according to what I heared earlier and from my own experience it is not the case, because Command condition still repopulates cache when it's invalidated. It's logical to suppose that it then uses this cache to get numbers.

Post has been edited 1 time(s), last time on Aug 5 2013, 8:51 pm by NudeRaider. Reason: merged 2 posts



Some.

Aug 4 2013, 9:47 pm jjf28 Post #5

Cartography Artisan

hmm... I find it hard to believe that they would cycle through all the units to update a list in the middle of a trigger cycle when they could go:

array[unitID] -= 1;

in the, say, remove unit trigger, unless they absolutely had to do a full update (for something like brings after remove unit).

Anyway, i'm just speculating, we'd need Heinermann or someone to have hard evidence.



TheNitesWhoSay - Clan Aura - github

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Aug 4 2013, 9:49 pm Wormer Post #6



I believe the reason SC doesn't use these tables is because Command may check for units owned by Foes or Allies that still requires to compare this data with players alliance statuses. It's not something you can just take from a table.

Yes, we need Heinermann! :) But, I believe Fyrinite is pretty good at this knowledge. He looks like a man who really knows the stuff and I have confidence in his words.



Some.

Aug 5 2013, 12:34 am Veta Post #7



deaths can also use foes and allies



None.

Aug 10 2013, 7:33 am rockz Post #8

ᴄʜᴇᴇsᴇ ɪᴛ!

Logically, command works identical to deaths.

12 * 228 = 2736

SC keeps track of all 12 players' command counts in the all unit counts table, so you you're looking for player 1 commands exactly 1 terran marine, it will be the first 4 bytes of the all unit counts table. Presumably player 13 (12) commands exactly 1 terran marine will look at ghosts.

Bring likely checks the unit table and matches unitID with an X and Y orientation within the limits of the specified location. It has to look at 1700*4*4*2 bytes, but it might have some builtin indexing somewhere which organize which unit slots of the 1700 are actually in use.



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

Aug 10 2013, 2:00 pm Wormer Post #9



rockz, like I said, according to this SC doesn't use this table to check units count, but checks the whole unit table instead. The only difference is that it doesn't match X and Y positions of the unit each time.



Some.

Aug 10 2013, 2:37 pm jjf28 Post #10

Cartography Artisan

It seems like the posts there were only describing location based commands/brings.

I think the fact that we have a table of the same size as, and at the same location as the death table, that has no significant purpose other than use in count-based conditions, constitutes strong enough evidence that they are using this table, but I wouldn't regard it as crazy if you didn't rest till you saw some dissasembled assembly code :P



TheNitesWhoSay - Clan Aura - github

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Aug 11 2013, 3:43 am rockz Post #11

ᴄʜᴇᴇsᴇ ɪᴛ!

Use a memory modifier and change the All Unit Counts Table so that terran marine is 1 for player 1, then run a trigger that runs when you command exactly 1 terran marine, and another when you bring 1 terran marine to anywhere.



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

Aug 11 2013, 6:48 am Wormer Post #12



That is a good idea. I tested this and figured out command doesn't read or write to All Unit Counts Table (AUCT). I repeated the same test with Completed Unit Counts Table (CUCT) and it looks like Command really reads data from there.

Also, the difference between AUCT and CUCT is that first includes units that started production in a factory (not queued but only the one that produces), but the latter only contains completed units. Maybe there are other differencies though.

Post has been edited 4 time(s), last time on Aug 11 2013, 7:07 am by Wormer.



Some.

Aug 11 2013, 4:13 pm Roy Post #13

An artist's depiction of an Extended Unit Death

Quote from Wormer
I repeated the same test with Completed Unit Counts Table (CUCT) and it looks like Command really reads data from there.
Which modifier were you using? I'm pretty sure that matters.
Quote from Quirks
  • The bring condition will not register the "At most" modifier, the trigger will simply behave as if that bring condition is absent / always true. "Exactly" and "At least" work as expected.
  • Incomplete buildings cannot be detected in any conditions that use the "at least" or "exactly" modifiers, but they can be counted using the "at most" modifier; unfortunately this is generally not very useful. Incomplete buildings will be considered for actions. Incomplete Zerg buildings morphing to higher forms, such as a Spire morphing into a Greater Spire, will be treated as the pre-morph building for all trigger conditions and actions.
The "at most" modifier should be checking the All Units Count Table, whereas "at least" and "exactly" should be checking the Completed Unit Counts Table.




Aug 11 2013, 7:39 pm Wormer Post #14



I've used exactly in my tests. As far as I remember (been long time) command condition doesn't suffer from these bugsfeatures with modifiers.

Quote
The bring condition will not register the "At most" modifier, the trigger will simply behave as if that bring condition is absent / always true. "Exactly" and "At least" work as expected.
You're joking. This must be cut from some context.

I also remember similar mess with bring condition and units in transports, but it's inside out: "exactly" and "at most" work just fine when "at least" doesn't count those units (if I'm still remembering right).

Honestly I don't remember anything about units in production with this regard, but still I believe a structure under construction is counted as a completed unit in CUCT. This is calling for more tests!

One thing I can't understand: what the heck command condition invalidates cache when it just reads values from a table?



Some.

Aug 11 2013, 7:44 pm Azrael Post #15



Quote from Wormer
I also remember similar mess with bring condition and units in transports, but it's inside out: "exactly" and "at most" work just fine when "at least" doesn't count those units (if I'm still remembering right).

You aren't; "at most" is the one that works differently.




Aug 11 2013, 7:46 pm Wormer Post #16



Quote from Azrael
Quote from Wormer
I also remember similar mess with bring condition and units in transports, but it's inside out: "exactly" and "at most" work just fine when "at least" doesn't count those units (if I'm still remembering right).

You aren't; "at most" is the one that works differently.

Growing old :hurr:

EDIT1:
Still I'm remembering right that it's not the same mess, but inside out in a different fashion: "at most" doesn't detect units in transport when it does detect buildings under construction. :P

EDIT2:
Quote from Wormer
As far as I remember (been long time) command condition doesn't suffer from these bugsfeatures with modifiers.
I'm wrong here. Command condition does suffer from the same modifiers problems with buildings under construction, but doesn't suffer with units in transports.

EDIT3:
Quote from Roy
The "at most" modifier should be checking the All Units Count Table, whereas "at least" and "exactly" should be checking the Completed Unit Counts Table.
I've made a test. You're right! Exactly like this.

Post has been edited 6 time(s), last time on Aug 11 2013, 8:19 pm by Wormer.



Some.

Aug 12 2013, 12:45 am Lanthanide Post #17



Quote from Wormer
Quote from Roy
The bring condition will not register the "At most" modifier, the trigger will simply behave as if that bring condition is absent / always true. "Exactly" and "At least" work as expected.
You're joking. This must be cut from some context.
You're right, Roy was quoting it out of context. It's from this wiki page: http://www.staredit.net/?p=oldwiki&s=142

I wrote it after my experience with the Blood Pressure Marathon map I was making. The context here is about Powerups: "at most" + "bring" doesn't work for powerups. It would probably work the way you expect for all other units, though.



None.

Aug 12 2013, 7:12 am Azrael Post #18



Quote from Lanthanide
The context here is about Powerups: "at most" + "bring" doesn't work for powerups. It would probably work the way you expect for all other units, though.

The problem with "at most" is that it only detects visible units; that's an easy way to summarize it. It does detect unfinished buildings, and does not detect units inside of other units. This is applicable to powerups as well, "at most" cannot detect them when they are being held by a worker unit (for all intents and purposes, the powerup is inside the worker unit).

However, it does detect them the rest of the time. The "at most" + "bring" combination works for powerups, like any other unit. It's when they're held by a worker that it becomes problematic.

I believe you were aware of this when you wrote it, as the line before that one specifically mentions the powerup being picked up by a worker, and the lines after that continue the "being picked up by a worker" theme. However, it wasn't mentioned in this line, so the critical fact that the powerup must be held by a worker is easily missed.




Aug 12 2013, 10:01 am Lanthanide Post #19



Yeah, you're probably right that the 'picked up by worker' applies to this specific line as well, judging by the content around it.

The way powerups are handled is really quite kooky; it explains why I was having so much difficulty with them giving random results, until l sat down and really experimented to work it out.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[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" 🎵
[2024-4-27. : 3:33 pm]
O)FaRTy1billion[MM] -- o sen is back
[2024-4-27. : 1:53 am]
Ultraviolet -- :lol:
[2024-4-26. : 6:51 pm]
Vrael -- It is, and I could definitely use a company with a commitment to flexibility, quality, and customer satisfaction to provide effective solutions to dampness and humidity in my urban environment.
[2024-4-26. : 6:50 pm]
NudeRaider -- Vrael
Vrael shouted: Idk, I was looking more for a dehumidifer company which maybe stands out as a beacon of relief amidst damp and unpredictable climates of bustling metropolises. Not sure Amazon qualifies
sounds like moisture control is often a pressing concern in your city
[2024-4-26. : 6:50 pm]
Vrael -- Maybe here on the StarEdit Network I could look through the Forums for some Introductions to people who care about the Topics of Dehumidifiers and Carpet Cleaning?
[2024-4-26. : 6:49 pm]
Vrael -- Perhaps even here I on the StarEdit Network I could look for some Introductions.
[2024-4-26. : 6:48 pm]
Vrael -- On this Topic, I could definitely use some Introductions.
Please log in to shout.


Members Online: Roy, lil-Inferno