BurgerLib
Public Member Functions | Static Public Member Functions | Private Attributes
Burger::Random Class Reference

A simple random number generator. More...

#include <brrandommanager.h>

List of all members.

Public Member Functions

 Random ()
 Static constructor.
void Delete (void)
 Delete memory allocated by Burger::Random::New(Word32).
void Init (void)
 Reset to a default state.
void RandomInit (void)
 Reset to a random state.
Word32 Get (Word32 Range=0)
 Return a 32 bit random number.
void SetSeed (Word32 NewSeed)
 Seed the random number generator.
Int32 GetSigned (Word32 Range)
 Return a signed value in a specific range.
float GetFloat (void)
 Return a float from 0.0f to 0.99999f.

Static Public Member Functions

static RandomNew (Word32 NewSeed=0)
 Create a new instance of Random.

Private Attributes

Word32 m_Array [17]
Word32 m_Seed
Word m_Index1

Detailed Description

A simple random number generator.

This class will create random numbers that are spread evenly across a 32 bit range.

Functions exist that will pre-bake numbers into specific ranges like Burger::Random::Get(Word32) and Burger::Random::GetSigned(Word32).

Note:
It's permissiable to make binary copies of this class.

Constructor & Destructor Documentation

Burger::Random::Random ( ) [inline]

Static constructor.

All this does is init the random number generator with a call to Burger::Random::Init().

See also:
Burger::Random::Init() and Burger::Random::SetSeed().

Member Function Documentation

Burger::Random::Delete ( void  ) [inline]

Delete memory allocated by Burger::Random::New(Word32).

If you create an instance via a call to New, use this function to dispose of it.

See also:
Burger::Random::Random() and Burger::Random::New(Word32).

Return a 32 bit random number.

Get a random number. Return a number between 0 through (Range-1) inclusive.

Parameters:
Range0 means return 32 bits as is, anything else means return 0 through (Range-1) inclusive.
Returns:
A random number in the specified range.

Return a float from 0.0f to 0.99999f.

Returns a random number in the range of 0.0f to 0.999999f. The numbers are spread evenly.

See also:
Burger::Random::GetSigned(Word32) and Burger::Random::Get(Word32).

Return a signed value in a specific range.

Return a random number between -Range and +Range (Inclusive) and it's a SIGNED value. If Range = 3, then the value returned is -2 to 2 inclusive. 0, and numbers higher than 0x7FFFFFFFU are illegal.

See also:
Burger::Random::Get(Word32) and Burger::Random::GetFloat().

Reset to a default state.

Init the random number generator to a KNOWN state. This will allow games to record just the joystick movements and have random actions repeat for demo playback.

See also:
Burger::Random::RandomInit().
Burger::Random * Burger::Random::New ( Word32  NewSeed = 0) [static]

Create a new instance of Random.

Create a new random number generator instance using the Burgerlib memory manager.

Parameters:
NewSeedA seed value for tighter control. Passed to Burger::Random::SetSeed(Word32).
Returns:
Pointer to instance, or NULL if out of memory.
See also:
Burger::Random::Delete() and Burger::Random::SetSeed(Word32).

Reset to a random state.

Init the random number generator with an "Anything goes" policy so programs will power up in an unknown state. Do NOT use this if you wish your title to have recordable demos.

This function will use a formula that assumes that the tick timer runs at a constant time base but the machine in question does not. As a result. The number of times Burger::Random::Get(Word32) is called is anyone's guess.

See also:
Burger::Random::Init().

Seed the random number generator.

Set the random number generator to a specific seed. This allows altering the random number flow in a controlled manner.

Parameters:
NewSeed32 bit seed value.
See also:
Burger::Random::Init().

Member Data Documentation