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
 

Romek

Super Moderator
Reaction score
964
File -> Preferences -> Test Map tab -> Uncheck "Use Fixed Random Seed"
 

Rapmaster

Ultra Cool Member
Reaction score
95
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
 

CaptainJack

New Member
Reaction score
2
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.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Normally, every number should have occurred around 13-17 times at most.

If random fails to meet your expectations, it is random indeed.
 

BarzahdX

Active Member
Reaction score
18
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.
 

lindenkron

You can change this now in User CP
Reaction score
102
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
 

Ouguiya

New Member
Reaction score
11
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
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> 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.
 

SFilip

Gone but not forgotten
Reaction score
634
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.
 

Strilanc

Veteran Scripter
Reaction score
42
(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%).
 

MindWorX

New Member
Reaction score
8
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.
 

Stryke

New Member
Reaction score
6
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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top