• 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.

[Trigger] Major problems with random integer numbers

Status
Not open for further replies.
Level 6
Joined
Jan 17, 2014
Messages
166
Hi,

i'm trying to make a trigger that creates an item on a location depending on the random integer number.

  • map initializinga
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Trigger - Turn off Red ShardsA Barrel1 Dies <gen>
      • Trigger - Turn off Red ShardsA SkeletonGrunt <gen>
      • Trigger - Turn off Red ShardsA Barrel2 Dies <gen>
      • Set RandomitemReda = (Random integer number between 1 and 10)
      • If (RandomitemReda Equal to 5) then do (Item - Create Red Shards at (Center of Red FragtionA <gen>)) else do (If (RandomitemReda Equal to 4) then do (Item - Create Red Shards at (Center of Red FragtionA2 <gen>)) else do (If (RandomitemReda Equal to 3) then do (Trigger - Turn on Red ShardsA Barrel1 Dies <gen>) else do (If (RandomitemReda Equal to 2) then do (Trigger
      • Floating Text - Create floating text that reads (String(RandomitemReda)) above Archmage 0060 <gen> with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
The only problem is, that the random number is the same everytime!
When i put the triggerevent on map initializing, the number is always 10 (highest number between 1-10)
When i put the triggerevent on 1 sec, i always get number 4
when i put the triggerevent on random number between 1-4 sec a always get number 3

Can someone let me why i don't get a random number everytime?
thx
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
The only problem is, that the random number is the same everytime!
Yes because your RNG is set to the same seed every time.

When i put the triggerevent on map initializing, the number is always 10 (highest number between 1-10)
Someone forgot to uncheck "fixed seed" from their editor options for map testing.

When i put the triggerevent on 1 sec, i always get number 4
Computers are not capable of randomness. They instead use a pseudo random generator which in reality is just a finite sequence with order such that it is as good as random and so large it is impossible to predict. If you set up the sequence at the same place and request the same number ranges from it you will logically get the same answer.

when i put the triggerevent on random number between 1-4 sec a always get number 3
Adding some human input to request extra random numbers (as happens in normal games) makes predicting the RNG as good as impossible.

Can someone let me why i don't get a random number everytime?
You do not in multiplayer games as the seed is more random (unless a hostbot is used to specifically set the seed).
 
Level 7
Joined
Mar 6, 2006
Messages
282
Quick note:

  • Time - Every (Random real number between 1.00 and 10.00) seconds of game time
That event is run only once, at map init, meaning that it generates a random number for that event, only once.

So if say, you get a random number of 4, then that event will essentially be:

  • Time - Every 4.00 seconds of game time
 
Status
Not open for further replies.
Top