|
BurgerLib
|
A simple random number generator. More...
#include <brrandommanager.h>
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 Random * | New (Word32 NewSeed=0) |
| Create a new instance of Random. | |
Private Attributes | |
| Word32 | m_Array [17] |
| Word32 | m_Seed |
| Word | m_Index1 |
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).
| Burger::Random::Random | ( | ) | [inline] |
Static constructor.
All this does is init the random number generator with a call to Burger::Random::Init().
| 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.
| Word32 Burger::Random::Get | ( | Word32 | Range = 0 | ) |
Return a 32 bit random number.
Get a random number. Return a number between 0 through (Range-1) inclusive.
| Range | 0 means return 32 bits as is, anything else means return 0 through (Range-1) inclusive. |
| float Burger::Random::GetFloat | ( | void | ) |
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.
| Int32 Burger::Random::GetSigned | ( | Word32 | Range | ) |
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.
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.
| 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.
| NewSeed | A seed value for tighter control. Passed to 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.
| void Burger::Random::SetSeed | ( | Word32 | NewSeed | ) |
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.
| NewSeed | 32 bit seed value. |
Word32 Burger::Random::m_Array[17] [private] |
Word Burger::Random::m_Index1 [private] |
Word32 Burger::Random::m_Seed [private] |
1.8.0