Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::Random Class Reference

A simple random number generator. More...

Inheritance diagram for Burger::Random:
Collaboration diagram for Burger::Random:

Public Member Functions

const Burger::StaticRTTIget_StaticRTTI (void) const noexcept override
 Get the description to the class.
 
 Random (uint32_t uNewSeed=728056387U) noexcept
 Static constructor.
 
void set_seed (uint32_t uNewSeed) noexcept override
 Seed the random number generator.
 
uint32_t get (void) noexcept override
 Return a 32 bit pseudo random number.
 
- Public Member Functions inherited from Burger::RandomBase
const Burger::StaticRTTIget_StaticRTTI (void) const noexcept override
 Get the description to the class.
 
uint32_t get_seed (void) const noexcept
 Return the random number seed.
 
void random_seed (void) noexcept
 Seed with a random value.
 
uint32_t get_uint32 (uint32_t uRange) noexcept
 Return a 32 bit random number.
 
uint32_t get_dice (uint32_t uDiceCount, uint32_t uDiceSize) noexcept
 Return a dice roll.
 
int32_t get_int32 (uint32_t uRange) noexcept
 Return a signed value in a specific range.
 
float get_float (void) noexcept
 Return a float from 0.0f to 0.99999f.
 
float get_float (float fRange) noexcept
 Return a float from 0.0f to fRange.
 
float get_symmetric_float (void) noexcept
 Return a float from -.0.99999f to 0.99999f.
 
float get_symmetric_float (float fRange) noexcept
 Return a float from -fRange to fRange.
 
double get_double (void) noexcept
 Return a double from 0.0 to 0.999999999.
 
- Public Member Functions inherited from Burger::Base
const char * get_class_name (void) const noexcept
 Get the name of the class.
 
virtual ~Base () noexcept=default
 Destructor.
 

Static Public Member Functions

static RandomNew (uint32_t uNewSeed=0) noexcept
 Create a new instance of Random.
 

Static Public Attributes

static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 
- Static Public Attributes inherited from Burger::RandomBase
static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 
- Static Public Attributes inherited from Burger::Base
static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 

Protected Attributes

uint32_t m_Array [17]
 Array of seed values (Polynomial)
 
uint32_t m_uState
 Last random number generated.
 
uint32_t m_uIndex
 First lookup index.
 
- Protected Attributes inherited from Burger::RandomBase
uint32_t m_uSeed
 Random number seed.
 

Detailed Description

A simple random number generator.


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

This algorithm uses a simple table and iterates over it using an index and bit rotation.

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

Constructor & Destructor Documentation

◆ Random()

Burger::Random::Random ( uint32_t uNewSeed = 728056387U)
noexcept

Static constructor.


Initialize the random number generator with a call to set_seed(uint32_t).

Parameters
uNewSeedNew seed value
See also
set_seed(uint32_t).

Member Function Documentation

◆ get()

uint32_t Burger::Random::get ( void )
overridevirtualnoexcept

Return a 32 bit pseudo random number.


Get a pseudo random number using the current algorithm. Return a 32 bit unsigned value.

Returns
A 32 bit pseudo random number.
See also
set_seed(uint32_t) or get_uint32(uint32_t)

Implements Burger::RandomBase.

◆ get_StaticRTTI()

const Burger::StaticRTTI * Burger::Random::get_StaticRTTI ( void ) const
overridevirtualnoexcept

Get the description to the class.


This virtual function will pull the pointer to the StaticRTTI instance that has the name of the class. Due to it being virtual, it will be the name of the most derived class.

Returns
Pointer to a global, read only instance of StaticRTTI for the true class

Reimplemented from Burger::Base.

◆ New()

Burger::Random *BURGER_API Burger::Random::New ( uint32_t uNewSeed = 0)
staticnoexcept

Create a new instance of Random.


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

Parameters
uNewSeedSeed value for the random number generator
Returns
Pointer to instance, or nullptr if out of memory.
See also
set_seed(uint32_t).

◆ set_seed()

void Burger::Random::set_seed ( uint32_t uNewSeed)
overridevirtualnoexcept

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
uNewSeed32 bit seed value.
See also
get(void) or get_seed(void) const

Implements Burger::RandomBase.

Member Data Documentation

◆ g_StaticRTTI

const Burger::StaticRTTI Burger::Random::g_StaticRTTI
static

The global description of the class.


This record contains the name of this class and a reference to the parent

◆ m_Array

uint32_t Burger::Random::m_Array[17]
protected

Array of seed values (Polynomial)

◆ m_uIndex

uint32_t Burger::Random::m_uIndex
protected

First lookup index.

◆ m_uState

uint32_t Burger::Random::m_uState
protected

Last random number generated.