• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Chance in Triggers

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
Hey guys, I am writing a simple trigger and seem to be having problems.
At the start of the game, I want 1 lever to be removed. Which lever is
removed is suppose to be random (50-50 chance)

  • Lever Setup
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Sound - Play QuestNew <gen>
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Less than or equal to 50
        • Then - Actions
          • Destructible - Remove Lever 2380 <gen>
        • Else - Actions
          • Destructible - Remove Lever 1914 <gen>
      • Trigger - Turn on Lever 3 Cinematic <gen>
Please don't tell me that I am getting unlucky and the same lever is being
removed each time. I've tested the map over 25 times and its the same
result each time. Does any1 know what I'm doing wrong?
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
Ok this is very wierd. I saved the random percentage into a real variable like you said.

  • test
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Set LeverChance = (Random real number between 0.00 and 100.00)
      • Game - Display to (All players) for 30.00 seconds the text: (String(LeverChance))

  • The result was the same every single time, 53.850.

  • If I changed the "Elasped game time" to something different, the number changed
    (still repeated but wasn't 53.850)

I also tested the game outside of the "Test Map" button, by launching
warcraft III and playing single player. The results:

8.864
13.141
96.624
78.250

So, the Test Map didnt work, but the actual game did. So I have my
solution, but im curious as to why the "Test Map" doesn't work properly???
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Thanks a lot, thats very helpful. I suppose that option is there to improve
load time in "Test Map" instances. Thanks again.
The Use Fixed Random Seed is aimed for users that wants to run an experiment in a controlled situation.
You may not understand this, but if you run enough experiments, you'll know that sometimes this option helps them, big time.
I, myself, sometimes find this option to be quite useful when running an experiment with the trigger (mostly random-type trigger).
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
From what i understand you want this to be a coinflip so why dont you use numbers between 1 and 2, 50-50
You've got point.
1 ~ 100 can be reduced to 1 ~ 2 (less evaluating - more performance)
But this value only works for 50% chance.

If you want a 1% chance interval, you can do
1 ~ 100

If you want a 10% chance interval, you can do
1 ~ 10

If you want a 100% chance interval, you can do
1 ~ 1
But this is stupid, you can just trigger the effect lol.

It totally depends on your chance percentage.
 
Level 8
Joined
Oct 26, 2008
Messages
387
You've got point.
1 ~ 100 can be reduced to 1 ~ 2 (less evaluating - more performance)
But this value only works for 50% chance.

If you want a 1% chance interval, you can do
1 ~ 100

If you want a 10% chance interval, you can do
1 ~ 10

If you want a 100% chance interval, you can do
1 ~ 1
But this is stupid, you can just trigger the effect lol.

It totally depends on your chance percentage.

Exactly


I've always considered reals to be "more random" for some reason. Although I suppose finding the lowest common denominator would be much more efficient.

I agree!
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I've always considered reals to be "more random" for some reason. Although I suppose finding the lowest common denominator would be much more efficient.
0.01 ~ 100.00 (10,000 value).

1 ~ 100 != 0.01 ~ 100.00

It is not the same.

But I guess if you know math, you can play with the value to make it correctly
0.01 ~ 1.00 (100 value - 1% interval)
0.01 ~ 0.10 (10 value - 10% interval)
0.01 ~ 0.01 (1 value - 100% interval)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
well, reals can work to up to 5+ digits, maybe thats why they are more accurate, more numbers to pick of
Even if you have 0.00001 ~ 1.00000, the result would be the same, because it's not the value is to compare, it is the value within the range is to compare.

Like what I said earlier;
1 ~ 100 (100 value)

But in reals;
0.01 ~ 1.00 (100 value)

You may think that using low value would get a perfect reading, NO.

It still assess 100 values, be it Integer or Real.

Therefore the accuracy for both Reals and Integers are the same.

Although, having more decimal place can get you more accurate reading, like 0.0001% per interval, but I think it's pretty useless as to compare (10,000++ values compared to 100 or 10).

Better to assess low range value.
 
Status
Not open for further replies.
Top