Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Another counting problem
Another counting problem
May 14 2014, 5:59 pm
By: sethmachine  

May 14 2014, 5:59 pm sethmachine Post #1



Hi,

I have a system of triggers that for some reason are not behaving for a specific instance. Perhaps I am near sighted but I cannot diagnose the problem. I will first describe the system and then give the offending triggers.

I use a counting system to count each player's buildings and then do some action for each building. Here is a case of counting a single building type.

Code
for each player 1 to i do:
 for each instance of building of type T:
     Give instance to P9
     //do some action
 endfor
 Give all instances back to Pi
endfor


At a more lower level, the triggers basically count all buildings sequentially for each player. This is because I only use P9 as the counting player and so first it counts P1, then P2, then P3, etc. Otherwise there is no way to maintain identity when giving back the buildings. Each player is assigned a "lock" that essentially prevents them from being counted until all previous players have been counted. Thus PN can only start counting once P1 - PN-1 have finished counting. In the case a player is missing, I have a series of triggers that detects this and automatically releases the lock for that player. Thus if the only players are P3, P4, and P8,the locks for P1, P2 and P5, P6, P7 will always be released.

The system has been working fine and dandy except for one case, where I count Terran Academies. For whatever reason, the system breaks at counting these and they don't get counted at all. In this case, as far as I can tell, P9 stops taking buildings from anyone so they no longer get counted. And he does not hold onto any buildings, e.g. a cycle completes but then never starts again. The break occurs usually around the 2nd or 3rd cycle of counting the Terran Academies. What I would want to believe is somehow a lock is not being released, or the conditions for starting counting are not being satisfied.

However, it doesn't make much sense to me that the system would break on this instance. This is because I use it for 7 other buildings, and none of them have ever broken. More peculiar is that the Terran Academy triggers are simply made from a single text macro as all of the correctly working cases. Thus I am stumped as to what the problem really is--it most likely is particular to the Terran Academy and how I handle the DCs for doing that counting.

I use two DCs for Terran Academy counting: Terran Academy DC, which serves as the timer (how long between each cycle), held by P8, and Cantina, held by each player, which serves as the lock. When Terran Academy DC is at 0, a player's Cantina is at 1, and all players before them have Cantinas of 0 (all locks released), then they begin to count. But I searched the entire trigger text for other uses of Cantina and Terran Academy deaths and could not find any trigger which might fumble these values. I post the relevant triggers now in hopes someone can point out a potential source of error in my expected behavior.

Counting Timer for Terran Academy


Counting for P1


Counting for P2


Releasing locks of missing players




None.

May 14 2014, 9:00 pm Wormer Post #2



I think the problem is when a player builds his first academy and already has 70 minerals, commands less than 150 men and less than 60 ghosts. When the first academy is under construction trigger
Trigger("Player 1"){
Conditions:
Deaths("Player 8", "Terran Academy", At most, 0);
Deaths("Current Player", "Cantina", At least, 1);
Bring("Current Player", "Terran Academy", "Anywhere", At least, 1);
Accumulate("Current Player", At least, 70, ore);
Command("Current Player", "Men", At most, 150);
Command("Current Player", "Terran Ghost", At most, 60);
Switch("Switch11", set);
Actions:
Move Location("Current Player", "Terran Academy", "Anywhere", "PSpawn2");
Preserve Trigger();
Comment("Spawn - Terran Academy - Terran Ghost - Center");
}
doesn't run, because Bring("Current Player", "Terran Academy", "Anywhere", At least, 1) is false. But Bring("Current Player", "Terran Academy", "Anywhere", Exactly, 0) is also false and trigger
Trigger("Player 1"){
Conditions:
Deaths("Current Player", "Cantina", At least, 1);
Bring("Current Player", "Terran Academy", "Anywhere", Exactly, 0);
Switch("Switch11", set);
Actions:
Give Units to Player("Player 9", "Current Player", "Terran Academy", All, "Anywhere");
Set Deaths("Current Player", "Cantina", Set To, 0);
Preserve Trigger();
Comment("Finish Spawn - Terran Academy - Terran Ghost");
}
that releases the DC doesn't run too.

This shouldn't result in an infinite block though, at least until player completes his first Academy, but you should change the first Bring to Command at least 1 Academy in any case.

How do you set switches P1, P2 and etc.?

Post has been edited 2 time(s), last time on May 14 2014, 10:10 pm by Wormer.



Some.

May 14 2014, 9:35 pm Roy Post #3

An artist's depiction of an Extended Unit Death

Quote from Wormer
Bring("Current Player", "Terran Academy", "Anywhere", At least, 1) is false. But Bring("Current Player", "Terran Academy", "Anywhere", Exactly, 0) is also false
Actually, if it's still in construction, "Bring exactly 0" would be true (only saying "at most 0" would make it false if the last remaining Academy is in construction).

I don't see anything within the posted triggers that would cause the system to halt.




May 14 2014, 9:54 pm Wormer Post #4



Quote from Roy
Quote from Wormer
Bring("Current Player", "Terran Academy", "Anywhere", At least, 1) is false. But Bring("Current Player", "Terran Academy", "Anywhere", Exactly, 0) is also false
Actually, if it's still in construction, "Bring exactly 0" would be true (only saying "at most 0" would make it false if the last remaining Academy is in construction).

I don't see anything within the posted triggers that would cause the system to halt.
Oh, OK. :omfg: My bad, then this trigger behaves not as exptected:
Trigger("Player 1"){
Conditions:
Deaths("Player 8", "Terran Academy", At most, 0);
Deaths("Current Player", "Cantina", At least, 1);
Bring("Current Player", "Terran Academy", "PSpawn2", Exactly, 0);
Accumulate("Current Player", At least, 70, ore);
Command("Current Player", "Men", At most, 150);
Command("Current Player", "Terran Ghost", At most, 60);
Switch("Switch11", set);
Actions:
Give Units to Player("Current Player", "Player 9", "Terran Academy", 1, "PSpawn2");
Preserve Trigger();
Comment("Spawn - Terran Academy - Terran Ghost - Incomplete");
}
Must be Bring("Current Player", "Terran Academy", "PSpawn2", At Most, 0) AFAIK. No that's wrong, must be the negation of Bring("Current Player", "Terran Academy", "PSpawn2", At Most, 0).

This is an off topic, but If I was doing triggers, I would have done it this way.

Counting Timer for Terran Academy

Counting for Player X, X = 1, 2, ..., 7


Post has been edited 12 time(s), last time on May 15 2014, 8:52 am by Wormer.



Some.

May 15 2014, 3:19 am sethmachine Post #5



Thank you for the quick responses and thanks Wormer for your method of doing it. I've been awake 24+ hours so I'm a bit groggy but I'll try your method out and see if it fixes this problem.

One thing I thought could have been relevant was if these errors were triggered by leaving players. I haven't observed this correlation exactly, and the missing turn triggers would handle that anyway, which are here for more context.

Checking of a player is missing




None.

May 15 2014, 7:02 am Wormer Post #6



I don't see problems with players leaving the game in your triggers. You can check if you don't accidentally give "phantom" players units after they leave, but I don't think this it's anything concerned with this. Try to do a small change that shouldn't break everything: for example change timer (P8 Academia DC) from 60 to 50 or 40 and see what happens.

I didn't want to overcomplicate but if you're going to use my triggers it's better to do it this way:
Set Deaths("Player 1", "Cantina", Set To, 2^6);
Set Deaths("Player 2", "Cantina", Set To, 2^5);
Set Deaths("Player 3", "Cantina", Set To, 2^4);
Set Deaths("Player 4", "Cantina", Set To, 2^3);
Set Deaths("Player 5", "Cantina", Set To, 2^2);
Set Deaths("Player 6", "Cantina", Set To, 2^1);
Set Deaths("Player 7", "Cantina", Set To, 2^0);
and change conditions to
Deaths("Magisters", "Cantina", At least, 2^(7-X) );
Deaths("Magisters", "Cantina", At most, (2^(8-X))-1 );
so that players who doesn't own complete buildings don't cause any delay.

EDIT:
You can also replicate "Counting for Player X" triggers however many times you want to speed up the process, but this will add for more map lag, because of giving many units in one trigger cycle. Ideally if you replicate this as much times as a player may own academies then you don't need Cantina DCs at all and triggers will look like:
Counting Timer for Terran Academy and other buildings

Counting for Magisters. Replicate as many times as max academies allowed.
Then you have this single finalization trigger
Finalize
You then need a subsystem that prevents players from building more academies that allowed.

If you know your maximum allowed academies (let's say 5) here is another solution to help against lag:
Counting for Player X, X = 1, 2, ..., 7.
Counting timer triggers are the same as in the previous example. If MaxAcad*7 > 60 and you don't want to increase the timer you may replicate "counting" triggers to handle several academies at a time.

EDIT2:
In conclusion. If you don't want to bother with limiting maximum number of academies then you need a synchronization switch such as Cantina. If you somehow limit the maximum number of academies that are allowed to have (which isn't a bad idea) you may get rid of synchronization switch and have two choices: fast and laggy or (not really much) slower but less laggy. To say, if you have enough building types then all these methods are pretty lag intense: the more players the worse.

Post has been edited 16 time(s), last time on May 15 2014, 9:04 am by Wormer.



Some.

May 15 2014, 8:10 pm death6373 Post #7



If you haven't fixed the problem already i could help out if you put the map up for download. I would be able to test out some things if i had the map



None.

May 15 2014, 9:08 pm sethmachine Post #8



Thanks again Wormer for the detailed reply and explanation. Still wrapping my head around it though haha.

In any case, I found the problem!

The triggers are indeed correct with their logic, except for one case:

Bring("Current Player", "Terran Academy", "PSpawn2", Exactly, 1);

This predicate is false if more than a single Terran Academy is inside PSpawn2. Thus the system breaks whenever this happens.

As it turns it, this happens when buildings are close/touching. Hence why it almost always happened for Terran Academy, but never for Terran Barracks, Terran Engineering Bay, etc.

Since I don't allow building stacking, I made my base case the scenario where all the Academies are made in a square touching each other, and then changed the location size, PSpawn2, to a single square. This seems to have solved the problem.

I made the location too big because of my misunderstanding how how spawning units works relative location size. I did not realize one could create a unit at a location which was smaller than the unit. So it seems to all be fixed now.



None.

May 15 2014, 9:35 pm Wormer Post #9



Glad I was useful in the end. Don't bother wrapping your head over my triggers, just go with what you already have in the map if it turns out to work fine for you.



Some.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[2024-5-12. : 8:51 pm]
l)ark_ssj9kevin -- Are you excited for Homeworld 3?
[2024-5-12. : 8:44 pm]
l)ark_ssj9kevin -- Hi Brusilov
[2024-5-12. : 4:35 pm]
O)FaRTy1billion[MM] -- Brusilov
Brusilov shouted: Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
my server that was hosting it died
[2024-5-10. : 8:46 pm]
NudeRaider -- Brusilov
Brusilov shouted: Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
https://armoha.github.io/eud-book/
[2024-5-10. : 8:36 am]
Brusilov -- Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
[2024-5-09. : 11:31 pm]
Vrael -- :wob:
[2024-5-09. : 8:42 pm]
Ultraviolet -- :wob:
[2024-5-08. : 10:09 pm]
Ultraviolet -- let's fucking go on a madmen rage bruh
[2024-5-08. : 10:01 pm]
Vrael -- Alright fucks its time for cake and violence
[2024-5-07. : 7:47 pm]
Ultraviolet -- Yeah, I suppose there's something to that
Please log in to shout.


Members Online: lil-Inferno