Drag[en]gine Game Engine  1.0
decPRNG Class Reference

Psuedo Random Number Generator. More...

#include <decPRNG.h>

Public Member Functions

Constructors and Destructors
 decPRNG ()
 Creates a new pseudo random number generator. More...
 
 decPRNG (unsigned int seed)
 Creates a new pseudo random number generator. More...
 
 ~decPRNG ()
 Cleans up the pseudo random number generator. More...
 
Management
void Reset ()
 Resets the pseudo random number generator to the construction state. More...
 
void Reset (unsigned int seed)
 Resets the pseudo random number generator with a new seed. More...
 
int RandomInt ()
 Retrieves the next random number as integer value. More...
 
int RandomInt (int lower, int upper)
 Retrieves the next random number as integer value. More...
 
float RandomFloat ()
 Retrieves the next random number as float value. More...
 
float RandomFloat (float lower, float upper)
 Retrieves the next random number as float value. More...
 
double RandomDouble ()
 Retrieves the next random number as double value. More...
 
double RandomDouble (double lower, double upper)
 Retrieves the next random number as double value. More...
 

Detailed Description

Psuedo Random Number Generator.

Provides a simple PRNG that works the same across all supported platform no matter the actual random implementation used by the platform.

Author
Pl├╝ss Roland
Version
1.0
Date
2014

Constructor & Destructor Documentation

◆ decPRNG() [1/2]

decPRNG::decPRNG ( )

Creates a new pseudo random number generator.

Uses the current system time as seed.

◆ decPRNG() [2/2]

decPRNG::decPRNG ( unsigned int  seed)

Creates a new pseudo random number generator.

Parameters
[in]seedThe seed to use.

◆ ~decPRNG()

decPRNG::~decPRNG ( )

Cleans up the pseudo random number generator.

Member Function Documentation

◆ RandomDouble() [1/2]

double decPRNG::RandomDouble ( )

Retrieves the next random number as double value.

Returns
Random number as double value in the range from 0 to 1.

◆ RandomDouble() [2/2]

double decPRNG::RandomDouble ( double  lower,
double  upper 
)

Retrieves the next random number as double value.

Parameters
[in]lowerThe lower value to map the random value to.
[in]upperThe upper value to map the random value to. If upper is less than lower upper is considered to be equal to lower.
Returns
Random number as double value in the range from lower to upper.

◆ RandomFloat() [1/2]

float decPRNG::RandomFloat ( )

Retrieves the next random number as float value.

Returns
Random number as float value in the range from 0 to 1.

◆ RandomFloat() [2/2]

float decPRNG::RandomFloat ( float  lower,
float  upper 
)

Retrieves the next random number as float value.

Parameters
[in]lowerThe lower value to map the random value to.
[in]upperThe upper value to map the random value to. If upper is less than lower upper is considered to be equal to lower.
Returns
Random number as float value in the range from lower to upper.

◆ RandomInt() [1/2]

int decPRNG::RandomInt ( )

Retrieves the next random number as integer value.

Returns
Random number as integer value in the range from 0 to DE_RANDOM_INT_UPPER.

◆ RandomInt() [2/2]

int decPRNG::RandomInt ( int  lower,
int  upper 
)

Retrieves the next random number as integer value.

Parameters
[in]lowerThe lower value to map the random value to.
[in]upperThe upper value to map the random value to. If upper is less than lower upper is considered to be equal to lower.
Returns
Random number as integer value in the range from lower to upper.

◆ Reset() [1/2]

void decPRNG::Reset ( )

Resets the pseudo random number generator to the construction state.

◆ Reset() [2/2]

void decPRNG::Reset ( unsigned int  seed)

Resets the pseudo random number generator with a new seed.


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