Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Trigger Behavior on empty player slots
Trigger Behavior on empty player slots
May 12 2014, 4:36 am
By: sethmachine  

May 12 2014, 4:36 am sethmachine Post #1



Hi,

(The triggers are attached below in a text file. Apparently there is a limit to the characters in these posts :[)

I have a series of triggers that assigns six unique options randomly, one for each player. Every player receives exactly one option, and no two players receive the same way. I discussed this problem in a previous post where I did at first a brute force solution. I reworked it and now have a more simple system that simply keeps generating a random number until it is matched to an option not chosen. Thus the core of the triggers is this:

Code
options = {City1, City2, City3, City4, City5, City6}
for each player 1 to 6 do:
 choice = options[random_int(1, 6)]
 while choice is already taken do:
     choice = options[random_int(1, 6)]
 assign choice to player i


Now this is the behavior I get from the triggers below. And I do observe some kind of "exponential" slow down of assignment, since it becomes increasingly more unlikely to generate a more constrained range of numbers (i.e. approaches 1/N probability where N = number of choices). The first player always gets his choice assigned first, but the last player takes a bit longer because it's a 1/6 chance repeating every trigger cycle.

Now I am not here to discuss making a better system (that was in the previous thread). Instead, while my system works when all 6 players are in game, it breaks when a player slot is empty. In particular I have been testing the following scenario, where P2 is empty but all other slots are taken.

When P2 is empty, I observe the following behavior.

1. P1 is correctly assigned an option randomly

2. P2 is correctly assigned an option randomly

3. P3-6 are never assigned anything afterwards--the system halts dead in its tracks.

The way the system constrains the choices is by a death counter (Zerg Queen's Nest) that is decremented each time a player is given an option.

When the DC = 6, only P1 can be assigned an option. When DC = 5, only P2 can be assigned an option, etc, etc.

Thus the normal behavior is this:
1. DC = 6
2. P1 assigned, --DC, DC = 5
3. P2 assigned, --DC, DC = 4
4. P3 assigned, --DC, DC = 3
5. P4 assigned, --DC, DC = 2
6. P5 assigned, --DC, DC = 1
7. P6 assigned, --DC, DC = 0
8. Finish, DC = 0

The bad behavior in the first case, however, sets DC = 0 after P2 runs (step 3) rather than decrement it by 1.

2. P1 assigned, --DC, DC = 5
3. P2 assigned, --DC, DC = 0 (????????????????????????)
4. Finish, DC = 0

I verified this by watching the leaderboard kills for the DC. Now I am not sure how being an empty player suddenly throws the system out. It's not in the semantics or logic that I understand. I know empty players cannot run triggers, and I also know conditions like "Command" do not work for empty players. But these triggers are run by P8, who is always in game, and the conditions use a series of "Brings," which DO work for empty players.

What am I misunderstanding here?

Attachments:
triggers.txt
Hits: 6 Size: 20.76kb



None.

May 12 2014, 11:17 am Wormer Post #2



All preplaced units of an empty player are removed at start of the game. Maybe this is the problem?



Some.

May 13 2014, 1:43 am rockz Post #3

ᴄʜᴇᴇsᴇ ɪᴛ!

Trigger("Player 8"){
Conditions:
Deaths("Player 8", "Zerg Queen's Nest", Exactly, 5);
Deaths("Player 8", "Protoss Assimilator", Exactly, 2);
Command("Player 2", "Protoss Nexus", At most, 0);
Bring("Force 1", "Buildings", "City3", At most, 0);

I doubt it's this. It sounds like there's something else subtracting or setting zerg queen's nest. Find that trigger and you'll figure it out.

IMO you should use random start locations or make 720 triggers which give the bases to the players. It would only take 19 triggers to get the random number under 720.



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

May 13 2014, 2:39 am Roy Post #4

An artist's depiction of an Extended Unit Death

The problem lies with one of the quirks and nuances regarding players and forces:
Quote from Wiki
When a player who belongs to a group, like Force 1, is not present in the game, any units created via triggers for Force 1 or given to that player will still be owned by that phantom player. Unusually however, the "remove unit" action when applied to the player's group will *not* remove the phantom player's units; instead you must use specifically remove units for that individual player.
Simply put, units that are owned by a "phantom player" (a player not in the game) are ignored by the force/all players groups (except when creating/giving). So saying "Force 1 Commands exactly 0 Nexus" when only Phantom Player 2 owns a Nexus will return as true, because Player 2 is not part of Force 1 in this regard.

Here's your problem in a nutshell:

Trigger Cycle 1:
  • Randomize which city to give (let's say it selects city #4)
  • Force 1 doesn't have buildings at City4 and Player 1 doesn't command a Nexus, so Player 1 receives all units owned by Player 7 there. Zerg Queen Nest subtracts by 1.
  • Force 1 has buildings at City4, so Player 2 doesn't receive anything.
  • Force 1 has buildings at City4, so Player 3 doesn't receive anything.
  • Force 1 has buildings at City4, so Player 4 doesn't receive anything.
  • Force 1 has buildings at City4, so Player 5 doesn't receive anything.
  • Force 1 has buildings at City4, so Player 6 doesn't receive anything.

Trigger Cycle 2:
  • Randomize which city to give (let's say it selects city #2)
  • Player 1 commands a Nexus, so Player 1 doesn't receive anything
  • Force 1 doesn't have buildings at City2 and Player 2 doesn't command a Nexus, so Player 2 receives all units owned by Player 7 there. Zerg Queen Nest subtracts by 1.
  • Force 1 doesn't have buildings at City2 and Player 3 doesn't command a Nexus, so Player 3 receives all units owned by Player 7 there. Zerg Queen Nest subtracts by 1.
  • Force 1 doesn't have buildings at City2 and Player 4 doesn't command a Nexus, so Player 4 receives all units owned by Player 7 there. Zerg Queen Nest subtracts by 1.
  • Force 1 doesn't have buildings at City2 and Player 5 doesn't command a Nexus, so Player 5 receives all units owned by Player 7 there. Zerg Queen Nest subtracts by 1.
  • Force 1 doesn't have buildings at City2 and Player 6 doesn't command a Nexus, so Player 6 receives all units owned by Player 7 there. Zerg Queen Nest subtracts by 1.

That's how your DC is dropping to zero immediately after an empty slot is processed. (And obviously Players 3-6 don't receive any units at City2 in the example because all of Player 7's units were given to Player 2.)

A quick and dirty solution to your problem is to change your "Bring("Force 1", "Buildings", "CityX", At most, 0);" conditions to "Bring("Player 7", "Buildings", "CityX", At least, 1);" as means of checking if the city has already been taken.

Post has been edited 1 time(s), last time on May 13 2014, 2:44 am by Roy.




May 13 2014, 7:02 am Lanthanide Post #5



Good sleuthing Roy :)

Glad I started that wiki page. It's proven invaluable. This is probably the most obscure case yet, though.



None.

May 13 2014, 7:37 am sethmachine Post #6



Thank you everyone for your replies and advice.

And many thanks Roy for finding the problem with this. I was perplexed because I knew this was the only spot where the DC was being subtracted.

My first guess would be that it would give all the cities to P2, but instead it tries to give everyone the cities he's already been dished out. That I did not really expect! I certainly lost a lot of hair over this one.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[10:53 pm]
Oh_Man -- https://youtu.be/MHOZptE-_-c are yall seeing this map? it's insane
[2024-5-04. : 1:05 am]
Vrael -- I won't stand for people going around saying things like im not a total madman
[2024-5-04. : 1:05 am]
Vrael -- that's better
[2024-5-04. : 12:39 am]
NudeRaider -- can confirm, Vrael is a total madman
[2024-5-03. : 10:18 pm]
Vrael -- who says I'm not a total madman?
[2024-5-03. : 2:26 pm]
UndeadStar -- Vrael, since the ad messages get removed, you look like a total madman for someone that come late
[2024-5-02. : 1:19 pm]
Vrael -- IM GONNA MANUFACTURE SOME SPORTBALL EQUIPMENT WHERE THE SUN DONT SHINE BOY
[2024-5-02. : 1:35 am]
Ultraviolet -- Vrael
Vrael shouted: NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
Gonna put deez sportballs in your mouth
[2024-5-01. : 1:24 pm]
Vrael -- NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
[2024-4-30. : 5:08 pm]
Oh_Man -- https://youtu.be/lGxUOgfmUCQ
Please log in to shout.


Members Online: NudeRaider, DarkenedFantasies