[DGD] Damage Weapons and Stuff (Math and Code)

Ben Chambers bjchamb at bellsouth.net
Tue Jun 3 01:35:10 CEST 2003


Yep, the gaussian distribution is the same as the normal distribution.  This
website shows how to create numbers in that have a mean of 0 and standard
deviation of 1 (the most common version of the normal distribution).
http://www.taygeta.com/random/gaussian.html

The code found there follows:
         float x1, x2, w, y1, y2;

         do {
                 x1 = 2.0 * ranf() - 1.0;
                 x2 = 2.0 * ranf() - 1.0;
                 w = x1 * x1 + x2 * x2;
         } while ( w >= 1.0 );

         w = sqrt( (-2.0 * ln( w ) ) / w );
         y1 = x1 * w;
         y2 = x2 * w;

As the websites explains, ranf is a function to return a random number in
the range [0, 1].  The problem is the number of calls that occur to ranf.
There is the potential that a lot of calls would be made.  How would DGD
handle this?  How fast is the random generation function in DGD?

_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list