#include <tRandom.h>

Public Member Functions | |
| tRandomizer () | |
| default constructor | |
| virtual | ~tRandomizer () |
| destructor | |
| REAL | Get () |
| returns a random float in the interval [0,1) | |
| int | Get (int max) |
| returns a random integer in the interval [0,max) | |
Static Public Member Functions | |
| static tRandomizer & | GetInstance () |
| returns the standard randomizer | |
Protected Attributes | |
| unsigned int | randMax_ |
Private Member Functions | |
| tRandomizer (tRandomizer const &other) | |
| copy constructor | |
| tRandomizer & | operator= (tRandomizer const &other) |
| copy operator | |
| virtual unsigned int | GetRawRand () |
| returns a raw random number | |
Definition at line 39 of file tRandom.h.
| tRandomizer::tRandomizer | ( | void | ) |
default constructor
Definition at line 53 of file tRandom.cpp.
00054 :randMax_( RAND_MAX ) 00055 { 00056 }
| tRandomizer::~tRandomizer | ( | void | ) | [virtual] |
| tRandomizer::tRandomizer | ( | tRandomizer const & | other | ) | [private] |
copy constructor
| other | copy source |
Definition at line 136 of file tRandom.cpp.
References tASSERT.
00137 { 00138 tASSERT( 0 ); // not implemented 00139 }
| REAL tRandomizer::Get | ( | void | ) |
returns a random float in the interval [0,1)
Definition at line 68 of file tRandom.cpp.
References a, b, GetRawRand(), randMax_, and REAL.
Referenced by gCycleChatBot::Activate(), ePlayer::ePlayer(), gGame::GameLoop(), Get(), nServerInfo::GetRandomMaster(), gArena::GetRandomPos(), gSpark::gSpark(), init_exp(), zSelector::pickOne(), nServerInfo::QueryServer(), Random(), nKrawall::RandomSalt(), nSocket::Read(), eAudioPos::Reset(), gGame::StateUpdate(), ve_math_random(), and nSocket::Write().
00069 { 00070 // Grr. VisualC 6 can't handle this in one line. 00071 REAL a = GetRawRand(); 00072 REAL b = randMax_; 00073 00074 return a / b; 00075 }


| int tRandomizer::Get | ( | int | max | ) |
returns a random integer in the interval [0,max)
| max | upper limit of the return value |
Definition at line 88 of file tRandom.cpp.
References floorf(), Get(), and tASSERT.
00089 { 00090 int ret = int( floorf( Get() * max ) ); 00091 tASSERT( 0 <= ret ); 00092 tASSERT( ret < max ); 00093 00094 return ret; 00095 }

| tRandomizer & tRandomizer::GetInstance | ( | void | ) | [static] |
returns the standard randomizer
Reimplemented in tReproducibleRandomizer.
Definition at line 107 of file tRandom.cpp.
Referenced by ePlayer::ePlayer(), gGame::GameLoop(), gSpark::gSpark(), init_exp(), zSelector::pickOne(), Random(), nKrawall::RandomSalt(), eAudioPos::Reset(), gGame::StateUpdate(), and ve_math_random().
00108 { 00109 static tRandomizer randomizer; 00110 return randomizer; 00111 }

| tRandomizer & tRandomizer::operator= | ( | tRandomizer const & | other | ) | [private] |
copy operator
| other | copy source |
Definition at line 152 of file tRandom.cpp.
References tASSERT.
00153 { 00154 tASSERT( 0 ); // not implemented 00155 00156 return *this; 00157 }
| unsigned int tRandomizer::GetRawRand | ( | void | ) | [private, virtual] |
returns a raw random number
Reimplemented in tReproducibleRandomizer.
Definition at line 169 of file tRandom.cpp.
Referenced by Get().

unsigned int tRandomizer::randMax_ [protected] |
Definition at line 51 of file tRandom.h.
Referenced by Get(), and tReproducibleRandomizer::tReproducibleRandomizer().
1.5.4