[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnubg] Dice Roll Generation

From: Michael Petch
Subject: [Bug-gnubg] Dice Roll Generation
Date: Thu, 14 Aug 2003 14:52:00 -0600

I was reviewing the dice generation algorithms on the weekend in more
detail than I had before, and I was curious about something.

I noticed that most of the dice generation is based on finding the
remainder of integer division (dividing a value by 6 and take

What I find odd about this is that relative lengths have been taken to
ensure the initial seeds are sufficiently random however using modulus
to define a range introduces a slight bias for certain remainders.

Of course the bigger the integer (16 bit or 32 bit), the less of a bias
there is - but it still exists. I would tend to agree for the purposes
of Backgammon the significance of such bias would probably never be
noticed, but it might be worth the time to consider dropping simple (x
mod 6)+1  (Yes, some algorithms don't use that method but most do) and
replacing it with an algorithm that maintains the uniform distribution
of the original values. Why would there be value? Because of course
people always complain about computer generated dice. If something
obvious makes certain rolls more likely then someone may take exception
to it.
I remember doing some work on debian a few years back, and someone had
created a pretty nice algorithm for maintaining uniform distribution for
a range of values from 0 to n given a stream of random bytes. I know
that such a change to the random generators would not be a big issue,
but does anyone really care?

Michael Petch <address@hidden>
CApp::Sysware Consulting Ltd.

Attachment: signature.asc
Description: This is a digitally signed message part

reply via email to

[Prev in Thread] Current Thread [Next in Thread]