Random number bug in the World Editor?

Ouguiya

New Member
Reaction score
11
Hello everyone!

I wanted to ask a short question about the world editor, since recently I have found a phenomenon which I find really unnerving.

You certainly all know the "Math - Random Integer / Real Number between x and y" function, in the GUI.
It's used for many things. Random game modes, random hero choosing, dynamic and unpredictable game events and so on.

The only problem: I have been asking myself lately if the randomness is truly random in Warcraft 3.

I made a quick test to see if my suspicions were correct. I made a simple, empty map, with a single trigger, which outputs a number every 2 seconds.
Writing down the number, and measuring how many times it occurs, should show if the trigger was truly random.

There were two tests: One with relatively low boundaries, and one with high ones.

First case: Random Number from 1 - 57
Measured numbers: 127
Result: The detailed result would be very long to list. suffice to say that a total of 5 numbers never occurred once, and 4 numbers occurred 5 times (even though every number should only appear around 2-3 times, statistically)

Second case: Random Number from 1-5:
Measured numbers: 77
Detailed result:
Number 1 occurred: 15 times
Number 2 occurred: 9 times
Number 3 occurred: 21 times (!)
Number 4 occurred: 18 times
Number 5 occurred: 14 times

Now I think you will agree, that this is quite off the scale. Normally, every number should have occurred around 13-17 times at most.

If one were to play a map, where there are 5 game modes, and the game mode is chosen randomly, the players will play game mode 3 more than twice as often as game mode 2.

What I wanted to ask, is if some people have also noted this "unrandomness" of the "random" function from the World editor, or if it is even a known bug.

If so, is there any way to "trick" the system so to get a good and well balanced result, a JASS function, maybe even a complex trigger designed ONLY to spit out good random numbers, since nobody likes to have a lot of possibilities, but only few options, because the random function is messed up.

Yours,

Ouguiya
 
File -> Preferences -> Test Map tab -> Uncheck "Use Fixed Random Seed"
 
I'm not really into statistics or math, but taking only 127 samples doesn't sound significant for 57 possible results. Try a few thousand!

Computers can't generate random numbers but they basically try to generate numbers that the user can't predict. Same seed means the same sequence of numbers. An easy way, unless you are doing important stuff like cryptograpghy, is to just base it off the current time or some value derived from the user's mouse movements (not saying you can do this in War3, but I'm talking general programming.) http://en.wikipedia.org/wiki/Pseudo-random_number
 
This isn't a bug, this is due to microprocessors not having an actual random function. As for some numbers not showing up, that is because the results are random, thus you won't get every number every time. Again a processor only knows 0 and 1 so results that are even close to random are probably beyond most people comprehension.
 
> Normally, every number should have occurred around 13-17 times at most.

If random fails to meet your expectations, it is random indeed.
 
Make 15 tests over and over, if they all have the same numbers, it's fixed, if not, it's actually random.

One irritating thing about randomness is truly grasping it's meaning. 800 numbers, 1 - 1000.. They could all be 62, nothing about randomness says it's supposed to be even, or equal. Unfortunately, even random % work this way. -,-

Example: This is my favorite example, because it always wins. You flip a coin, it can be heads every time, but it's still 50%. ^^ Note: Not taking into account the actual coin flipper, and how one flipped the coin, such variables do not exist in my example of fact.
 
Make 15 tests over and over, if they all have the same numbers, it's fixed, if not, it's actually random.

One irritating thing about randomness is truly grasping it's meaning. 800 numbers, 1 - 1000.. They could all be 62, nothing about randomness says it's supposed to be even, or equal. Unfortunately, even random % work this way. -,-

Example: This is my favorite example, because it always wins. You flip a coin, it can be heads every time, but it's still 50%. ^^ Note: Not taking into account the actual coin flipper, and how one flipped the coin, such variables do not exist in my example of fact.

Exactly.

Theres the same % chance of each number between 1-1000 of happening .. but as I wrote .. Random .. Is random. So 999 or 1000 or what ever number, could happen 1000 times in a row. Which is what random is .. It's .. Random :D
 
Unfortunatly however, I have to add, that there is also a way of calculating the chance of getting always the same number.

thing is: It COULD happen, that 1000 comes 1000 times, but in that case one should really ask himself, if the random really is random.

Normally, if the system truly is random, you should get an equal distribution. Same with the coin: It COULD happen that you always get heads, but seriously: How often does this happen? Answer: alsmost never. Because it's not very probable. Same with the 1000 a thousand times thingy: The chance for this to occur in a row would be 1 / 1000 (because the numbers go from 1-1000), and then this 1000 times, meaning: 1/(1000*1000*1000*1000*1000...), a REALLY low number.

Now to step away from all the maths (cause to be honest, I hate probability and statistics calculation. It makes my head hurt.)

To get back to realism: In theory it IS possible, that if you toss a dice, you would always get the number 6 say. But try that in a casino... If you really always get 6, I guess the casino guards would quickly circle around you, and serioulsy check the dice for manipulation ;).

The reason for this? It never happens that you always get the same numbers. It could happen, but we all know that it doesn't. For: As probable as it is you get the same number, it is (x-1)/x more probable to get the other numbers (with x beeing the amount of numbers you can get. In case of the dice, x would be 6). At least if the system truly generates a random number every time it is activated (in case of the dice: rolled).

However, I do want to thank the first two replies very much (and all the others too), who gave at least some hints as to how make the randomness better.

Yours,

Ouguiya
 
> who gave at least some hints as to how make the randomness better

Post #3 applies to "test map" only. And is an actual feature.

Post #2 helps nothing...
Seeding a random generator with itself improves nothing...


> you should get an equal distribution

Actually, you do.
Sooner or later, the generator will repeat its sequence...
However, that only happens after about 4 billion calls (on a 32 bits generator).

Other than that, it's random already.


> It never happens that you always get the same numbers.

That is what you expect. Your expectations aren't random though.
 
77 times? That's way to small to mean anything.
GetRandomInt(1,5) 10000 times:
1 occurred 2000 times.
2 occurred 2026 times.
3 occurred 1972 times.
4 occurred 1990 times.
5 occurred 2012 times.
 
(Replying to original post)

Your first case makes it obvious you don't do a lot of statistics. The odds of every result showing up 2 or 3 times are very, very small. It's very likely that at least one will have less than 2 or more than 3 elements. In fact it's very likely that a bunch of them will.

If you do more samples you will find that these variations contribute less and less to your totals. Try doing ten thousand samples [use code, not paper] instead of 127, and you'll find the results don't vary by +- 50% anymore.

Just don't extrapolate that into some sort of "the universe evens out" gambler's fallacy BS. The actual magnitude of the differences will increase (+-100 instead of +-3), even though the percentage variations decrease (+-1% instead of +-50%).
 
I know it's a late response, but if you really want to have "even random" numbers, use a stack, fill the stack with the numbers 0..n, then remove a random number from the stack, until it's empty, and refill it with numbers from 0..n, that should give you "even random".

EDIT: Also, a quick note about you thinking that it's possible to throw multiple sixes in a row, but it just doens't happen, is not true. I play dungeons and dragons once a week, and i've experienced up to 4 20's in a row on a 20sided die, more than once too, that's a 1/160000 chance.
 
There is no way to make something truly random.
How WE probably makes random numbers is probably using a value that is always changing such as time, and selects a 'random' number by using a formula involving time.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top