How random is random?

Luth

Lex Luthor!
Reaction score
41
Every 499 seconds over an 1:40 hour game, I display I2S(GetRandomInt(0, 36)). Every B.net game (not WE games with fixed seeds), I see the same numbers far too often. Every game, without exception, I see 26. Often multiple times in the same game.

Is this normal? Is there any Seed function I can call to get a better set of random pulls?
 

Tonks

New Member
Reaction score
160
Computers can't really be entirely random. There's always a pattern, somewhere. Chances are, that pattern is intensely complex and long and difficult to figure out. Does it really matter though? It's pretty random, anyway, isn't it?
 

Luth

Lex Luthor!
Reaction score
41
Tonks said:
Computers can't really be entirely random. There's always a pattern, somewhere. Chances are, that pattern is intensely complex and long and difficult to figure out. Does it really matter though? It's pretty random, anyway, isn't it?

1) Yes, I know how random functions work. I've written them before.
2) It does matter, as if you'd read above, its entirely not random, and I'm seeing the same 3 numbers repeated again and again, game after game, for a week now, with very infrequent other results.

If you draw 10 random numbers beetween 0 and 36, and you get 26 six times, then something is wrong with the random function, it can be assumed.

So there's no seed or reseed function?
 
M

Mythic Fr0st

Guest
hmm

Hmm, I get the same thing with strings...

however, with 100-150 strings that display, out of 100 the same word appears maybe only 1-3 times each, probably 4 for the occasional rare one..

If you have enough numbers, its more likely to repeat less, thats the only thing I could think of -.-
 

Sim

Forum Administrator
Staff member
Reaction score
534
Random is meant to have numbers come out more often, simply because chances happen at random. Random numbers aren't meant to come out at least once each. They are meant to appear *randomly*, that means not equally divided, but RANDOMLY! :p

That would also mean that 1 number can appear more than another, and a second number only 1 time out of 500 tries. Because it is random. There are no rules. Try rolling dices, the same will happen. You could get 6 times a "7" roll in-a-row with a perfectly balanced die. But it doesn't mean randomness itself is screwed because of it.

Maybe randomness is miscalculated in JASS' functions, though. Dunno!

Just my 2 cents :p
 
V

Virgin-Flesh

Guest
It sounds like you have too much time on your hands ;)
There is a native function in common.j:
SetRandomSeed (integer seed)
Try messing with that.
 

Luth

Lex Luthor!
Reaction score
41
Virgin-Flesh said:
It sounds like you have too much time on your hands ;)
There is a native function in common.j:
SetRandomSeed (integer seed)
Try messing with that.

Perfect. :) Thanks for answering the question.

Dax, you should familiarize yourself with the notion of statistical probability; its what random functions mimic, and when they dont, there's something wrong.
 

N2o)

Retired.
Reaction score
51
Hmm i made a horse racing map for my mate, with random move speed and a betting system. I could bet the 1st 5 horses from memory and they'd win.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> If you draw 10 random numbers beetween 0 and 36, and you get 26 six times, then ...

Well, if that's not random...



With 10 tries of "Random integer from 1 to 2" and these results:
1212121212,
1122112211,
1111122222,
1111111112,
1221112222.

Which one is more random?
 
B

bakasora

Guest
Player 12 drop items
Events
Unit - A unit owned by Player 12 (Brown) Dies
Conditions
And - All (Conditions) are true
Conditions
((Triggering unit) is A ground unit) Equal to True
Actions
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 5
Then - Actions
Item - Create Tome of Agility at (Position of (Triggering unit))
Else - Actions
Do nothing


5% chance to drop?
how random can it be
 

Mr Zero

Junior Regular (Got the T-shirt)
Reaction score
64
AceHart said:
> If you draw 10 random numbers beetween 0 and 36, and you get 26 six times, then ...

Well, if that's not random...



With 10 tries of "Random integer from 1 to 2" and these results:
1212121212,
1122112211,
1111122222,
1111111112,
1221112222.

Which one is more random?

Haha, I wanna know one of them is the random :p.

But if you choose random you can get 1 all the time since there is no rules (unless you choose the start number).

Maybe you have a better system :rolleyes:?
 

Luth

Lex Luthor!
Reaction score
41
AceHart said:
> If you draw 10 random numbers beetween 0 and 36, and you get 26 six times, then ...

Well, if that's not random...



With 10 tries of "Random integer from 1 to 2" and these results:
1212121212,
1122112211,
1111122222,
1111111112,
1221112222.

Which one is more random?


That's 60% on 50% odds. Thats within normal standard deviation tolerance. 60% on a 2.77% bet is not. Those chances are roughly 1 in 2.4 billion to hit 60% accuracy on those odds.

Can it happen by random happenstance? Yes. However, if it does happen, being thinking creatures (well, most of us, anyway), we can look at it and say "Hey, there's probably something else influencing these results." So it seems to me that their Rand func is either not being properly seeded in B.net games, or the Rand func isnt well written. However, its likely that they're using the std C library's rand() func, which I know to be adaquate, hence the (now answered) question about Seeding.

So now I have it being periodically reseeded based on player events (such as chat strings) which are not likely to yield duplicate results. Today marks a new week of testing, so we'll see if it works as planned. :cool:
 
T

ThePixelator

Guest
I have the problem of non-randomness also. I have a map I made, and there is a random hero function. EVERY game, without exception, ever, out of the 54 times I have played with a full 10 players (yes I have counted), there has always been a blademaster and a shadow hunter. ALWAYS. out of 30 heros. Thats not random, and dont try to tell me it is.

If there is a better way to get random choices, I REALLY wanna know. Like, +rep wanna know. And, unlike some of the previous responses, try to avoid jass please, it scares me. :D

EDIT: PS. I have absolutely no idea what seeding is in any way, shape, or form, and no idea how the random functions work.
 
G

Goauld

Guest
Well, if Warcraft III had a better random function it would probably require a better system because of that.

If you want more randomness you could do from each integer variable from 1 to random number between 2 and 57, and then set variable to a random number between 0 and 36, and then use the last it gets, or even better use array and use random array of it.
 

Luth

Lex Luthor!
Reaction score
41
I put this trigger in. I'll be testing its results this week. (Hopefully far less 26s) It reseeds the random number generator every 5 minutes with the string length of the next-typed chat message + a random int. (No real reason why I used both; I'm mostly just sick of seeing 26) :cool:

Feel free to try your own tests with it, or something similiar:
Code:
 Seed Random
    Events
        Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
        Player - Player 2 (Blue) types a chat message containing <Empty String> as A substring
        Player - Player 3 (Teal) types a chat message containing <Empty String> as A substring
        Player - Player 4 (Purple) types a chat message containing <Empty String> as A substring
        Player - Player 5 (Yellow) types a chat message containing <Empty String> as A substring
        Player - Player 6 (Orange) types a chat message containing <Empty String> as A substring
        Player - Player 7 (Green) types a chat message containing <Empty String> as A substring
        Player - Player 8 (Pink) types a chat message containing <Empty String> as A substring
        Player - Player 9 (Gray) types a chat message containing <Empty String> as A substring
        Player - Player 10 (Light Blue) types a chat message containing <Empty String> as A substring
    Conditions
    Actions
        Custom script:   call SetRandomSeed( StringLength(GetEventPlayerChatString()) + GetRandomInt(7,777))
        Trigger - Turn off (This trigger)
        Wait 300.00 seconds
        Trigger - Turn on (This trigger)
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> That's 60% on 50% odds.
> That's within normal standard deviation tolerance.
> 60% on a 2.77% bet is not.
> Those chances are roughly 1 in 2.4 billion to hit 60% accuracy on those odds.

Uhm... what?

> Can it happen by random happenstance? Yes.

Well, if that's not random...


> ALWAYS. Out of 30 Heroes.

Well, if that's not random...


Actually, if "random" does not meet your expectations.. it is random.
There is no "I got '1' 99 times, if I don't get '2' now, random is broken"...
Random doesn't keep any history.

And, using a custom seed only makes sense if you want to repeat a given sequence.
Otherwise, the one provided by the game will certainly beat yours.
It has better choices, like the computer's running time, or some internal CPU scratch register.
String length is a rather limited choice.
And using the random generator to seed itself can't improve its quality.



And, to answer my own question from up here, each result is equally likely, and equally random.


John von Neumann said:
Anyone who considers arithmetical methods of producing random numbers is, of course, in a state of sin.
 

Luth

Lex Luthor!
Reaction score
41
> > That's 60% on 50% odds.
> > That's within normal standard deviation tolerance.
> > 60% on a 2.77% bet is not.
> > Those chances are roughly 1 in 2.4 billion to hit 60% accuracy on those odds.

> Uhm... what?

Its statistics. Unweighted choice between 1 and 2 yields 50% odds for either for either one. Unweighted choice between 0 and 36 is (actually, I was off. I calced 36 numbers instead of 37) 2.70% for any one coming up. The chance of hitting one number between 0 and 36 with a 60% success rate is about (3.11 x 10^-8)% chance in happening, or (again, 37 instead of 36) 1 in 3,213,743,427.

> > Can it happen by random happenstance? Yes.

> Well, if that's not random...

It appears to not be random.


> > ALWAYS. Out of 30 Heroes.

> Well, if that's not random...

It appears to not be random.


> Actually, if "random" does not meet your expectations.. it is random.
> There is no "I got '1' 99 times, if I don't get '2' now, random is broken"...
> Random doesn't keep any history.

Which is why I cant claim for sure that Random is broken. The best I can do is provide statistical analysis, which I have. Statistically speaking, if your strictly non-random equation for generating "random" numbers does not come close to matching the probability of distributions, it is 'broken'. It'd be akin to: int Random(int low, int high) { return low; }. You can call it a random function, but because it doesnt come close the matching the probability of distributions, it is 'broken' or, at least, works very poorly.

> And, using a custom seed only makes sense if you want to repeat a given sequence.
> Otherwise, the one provided by the game will certainly beat yours.

Maybe, but I am putting my bet on not. Its internal seeding mechanism is giving me a 60% success rate on a 2.7% bet. With those odds, I would take $10 and break vegas in an hour.


> It has better choices, like the computer's running time, or some internal CPU scratch register.
> String length is a rather limited choice.
> And using the random generator to seed itself can't improve its quality.

If I get a higher than 60% success rate with this new seeding system, then thats evidence that my system performs worse than theirs. If I get lower, then thats evidence that my system performs better than theirs. If you ignore statistics, then you're just stating opinion, and thats not worth discussing.
 
T

ThePixelator

Guest
You just told me that "randomly" getting the 2 same heros out of 30 heros, 54 times in a row without exception, is random. Do you realize that if it really is randomly choosing the heros, then the chance of this happening is 3240 to 1 (I think). So I SERIOUSLY doubt that it really is random.

There is some pattern it is following, a very baddly written, VERY not-random pattern.
 

Luth

Lex Luthor!
Reaction score
41
Well, chances are it's using the C-lib rand() function, which is adaquate. Programers are lazy, and unless there's a reason to rewrite something that exists, we wont. :) Typically, too, we seed the rand with GetClockTick or something equally non-repeatable. However, its possible that they chose a poor seed factor, which is why we many people see unexpected repetitions. I would wager, between those two choices, its the later.

Also...
I just tested my seeder on B.net. Not one duplicate number, and not once did 26 turn up in 1 hr 40 mis. The first time ever. :cool:
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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