• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] GetRandomReal not random ?

Status
Not open for further replies.

Ardenian

A

Ardenian

I use a function in my map that requires a local real r to be set to GetRandomReal( 0.00, 100.00):

JASS:
set r = GetRandomReal( 0.00, 100.00)

It is supposed to run multiple times. However, it did not work appropriate.

After hours of debugging and desperatly beating my head against the walls I debugged r and noticed: It is not random!

Every game, the 'random' values are exactly the same!
Is this a known issue ? It is absolutly impossible the reason for this lies elsewhere. How can I workaround this ?

The function is written in a converted GUI trigger, not the map header.
 
After hours of debugging and desperatly beating my head against the walls I debugged r and noticed: It is not random!
Well obviously. It is caused "pseudo random number generation" for a reason. They have very low statistical correlation but they are still not truly random since knowing the previous state of the system you can predict the future state (not something possible with truly random numbers as they have no relation to past state values).

Every game, the 'random' values are exactly the same!
Only if the seed is the same. This is different every time a game starts. Exception is when testing from the editor where you can use "fixed seed" for testing purposes.

Is this a known issue ?
Nope because there is no such issue.

It is absolutly impossible the reason for this lies elsewhere.
Same seed between sessions. Chance of this happening in multiplayer is practically impossible and even then the slightest change in game state (eg an attack at a different time) will cause the seed to deviate.

How can I workaround this ?
Nothing to work around. You can turn off fixed seed when testing from the editor preferences which will give you random results closer to what you will experience multiplayer or playing custom game.

As far as you should be concerned the random integers and reals are random between sessions.
 
Ahhh, I understand, thank you! I wasn't aware of that setting.
 
well as I said, there is a way to get completly random data from the game, but not at the beginning.

But you can use something like sumation of X coordinates of positions of all units belonging to some player, if your game allows unit movement that is, you get random data that should be random enough from one session to another, but as I said the drawback is you have to wait certain time to get such data. Also idiot-proofnes for cases when units dont move for instance need to be accounted for.
 
Status
Not open for further replies.
Back
Top