CrystalSpace

Public API Reference

csRandomGen Class Reference

Portable random number generator class. More...

#include <csutil/randomgen.h>

List of all members.

Public Member Functions

 csRandomGen (uint32 iSeed)
 Initialize the random number generator given a seed.
 csRandomGen ()
 Initialize the random number generator using current time().
uint32 Get (uint32 iLimit)
 Get a uint32 integer random number in range 0 <= num < iLimit.
float Get ()
 Get a floating-point random number in range 0 <= num < 1.
void Initialize (uint32 iSeed)
 Select the random sequence number (942,438,978 sequences available).
void Initialize ()
 Initialize the RNG using current time() as the seed value.
bool SelfTest ()
 Perform a self-test.

Detailed Description

Portable random number generator class.

The reason for using this class if that you may want a consistent random number generator across all platforms supported by Crystal Space. Besides, in general it is a better quality RNG than the one supplied in most C runtime libraries. Personally I observed a significant improvement in a random terrain generator I made after I switched to this RNG.

Definition at line 58 of file randomgen.h.


Constructor & Destructor Documentation

csRandomGen::csRandomGen (  )  [inline]

Initialize the random number generator using current time().

Definition at line 66 of file randomgen.h.

csRandomGen::csRandomGen ( uint32  iSeed  )  [inline]

Initialize the random number generator given a seed.

Definition at line 69 of file randomgen.h.


Member Function Documentation

uint32 csRandomGen::Get ( uint32  iLimit  ) 

Get a uint32 integer random number in range 0 <= num < iLimit.

float csRandomGen::Get (  )  [inline]

Get a floating-point random number in range 0 <= num < 1.

Definition at line 78 of file randomgen.h.

void csRandomGen::Initialize ( uint32  iSeed  ) 

Select the random sequence number (942,438,978 sequences available).

void csRandomGen::Initialize (  ) 

Initialize the RNG using current time() as the seed value.

bool csRandomGen::SelfTest (  ) 

Perform a self-test.


The documentation for this class was generated from the following file:

Generated for Crystal Space 2.0 by doxygen 1.6.1