Main Page   Class Hierarchy   Compound List   File List   Compound Members  

GlRandom Class Reference

Random number generators (including the rand() in C) are often frustratingly non-random in their lower bits. More...

#include <glrandom.h>

List of all members.

Public Methods

 GlRandom (U32 _seed=0)
 Constructor, with optional seed value.

void SetSeed (U32 _seed)
 The current seed can be set at any time. More...

U16 Rand ()
 Returns a 16bit random number.

U16 Rand (U16 upperBound)
 Returns a random number greater than or equal to 0, and less that 'upperBound'.

U16 RandD2 (U16 upperBound)
 "Roll two dice." Return a result from [0,upperBound). More...

U16 RandD3 (U16 upperBound)
 "Roll three dice." Return a result from [0,upperBound). More...

double DRand (double upper)
 Return a random number from 0 to upper: [0,upper].

float FRand (float upper)
 Return a random number from 0 to upper: [0,upper].

bool Boolean ()
 Return a random boolean.


Detailed Description

Random number generators (including the rand() in C) are often frustratingly non-random in their lower bits.

This is a fast random number that is random in its lower bits.


Member Function Documentation

U16 GlRandom::RandD2 U16    upperBound [inline]
 

"Roll two dice." Return a result from [0,upperBound).

This has the same bell curve distribution as 2 dice.

U16 GlRandom::RandD3 U16    upperBound [inline]
 

"Roll three dice." Return a result from [0,upperBound).

This has the same bell curve distribution as 3 dice.

void GlRandom::SetSeed U32    _seed
 

The current seed can be set at any time.

This does put the random number generator in a consistent state, even though the random numbers are actually partially cached.


The documentation for this class was generated from the following file:
Generated on Mon Sep 15 12:01:11 2003 for Kyra by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001