# [MUD-Dev] [DGN] The psychology of random numbers

Byron Ellacott bje at apnic.net
Tue Jan 27 16:33:06 New Zealand Daylight Time 2004

```On Fri, 2004-01-23 at 19:23, Hans-Henrik Staerfeldt wrote:

> Now, such a small skew can be extremely difficult to detect if you
> don't keep an extremely accurate track of all your rolls. I
> seriously doubt that any player will yell 'Hey why the f*** don't
> I ever roll an 11?'.

It's been my experience that players tend more to scream, 'Hey, why
the f*** have I just failed four times in a row?'  The other part of
the original post was about streaks, which are a little less obvious
to measure.

I wrote a short program that measured the number of times "rand() %
100 >= 10", reporting the longest streak at various intervals.  The
program rolled the "dice" 10,000,000 times per run, and did 100
runs.  Each run the RNG was seeded with the last rand() from the
previous sequence, and initially was seeded with a rand() based on
srand(time(NULL)).  The results, with glibc 2.3.2, are what I'd
expect:

At 10 rolls, the longest streak averaged 0.78.
At 100 rolls, the longest streak averaged 1.78.
At 1000 rolls, the longest streak averaged 2.65.
At 10000 rolls, the longest streak averaged 3.80.
At 100000 rolls, the longest streak averaged 4.80.
At 1000000 rolls, the longest streak averaged 5.62.
At 10000000 rolls, the longest streak averaged 6.63.

This suggests that hitting glibc's RNG with a modulo introduces a
skew so small as to be difficult to distinguish.  However, players
aren't ruled by numbers.  A player whose spell fizzles four times in
a row is going to notice and probably be unimpressed.  Despite it
being statistically likely, a common reaction is to blame the game.

Players on my MUD have asked me several times to look into the
random numbers they get.  The only problem I've ever managed to find
has been sample sizes that are far too small to draw any useful
conclusions -- and one fencepost bug ;)

--
bje
_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev

```