#include <tRandom.h>
Public Member Functions | |
tReproducibleRandomizer () | |
default constructor | |
~tReproducibleRandomizer () | |
destructor | |
Static Public Member Functions | |
static tReproducibleRandomizer & | GetInstance () |
returns the standard reproducible randomizer | |
Private Member Functions | |
virtual unsigned int | GetRawRand () |
returns a raw random number | |
Private Attributes | |
int | z_ |
int | w_ |
Definition at line 60 of file tRandom.h.
tReproducibleRandomizer::tReproducibleRandomizer | ( | void | ) |
default constructor
Definition at line 185 of file tRandom.cpp.
References tRecorder::PlaybackStrict(), tRandomizer::randMax_, tRecorder::Record(), recordingSection, w_, and z_.
00186 { 00187 // generate random seeds with standard random generator 00188 z_ = rand(); 00189 w_ = rand(); 00190 randMax_ = 0xffffffff; 00191 00192 // archive seed 00193 tRecorder::PlaybackStrict( recordingSection, z_ ); 00194 tRecorder::Record( recordingSection, z_ ); 00195 00196 tRecorder::PlaybackStrict( recordingSection, w_ ); 00197 tRecorder::Record( recordingSection, w_ ); 00198 00199 /* 00200 // read RAND_MAX from recording or write it to recording 00201 if ( !tRecorder::PlaybackStrict( recordingSection, randMax_ ) ) 00202 tRecorder::Record( recordingSection, randMax_ ); 00203 */ 00204 }
tReproducibleRandomizer::~tReproducibleRandomizer | ( | void | ) |
tReproducibleRandomizer & tReproducibleRandomizer::GetInstance | ( | void | ) | [static] |
returns the standard reproducible randomizer
Reimplemented from tRandomizer.
Definition at line 229 of file tRandom.cpp.
Referenced by gCycleChatBot::Activate(), gArena::GetRandomPos(), and nWaitForAck::nWaitForAck().
00230 { 00231 static tReproducibleRandomizer randomizer; 00232 return randomizer; 00233 }
unsigned int tReproducibleRandomizer::GetRawRand | ( | void | ) | [private, virtual] |
returns a raw random number
Reimplemented from tRandomizer.
Definition at line 245 of file tRandom.cpp.
00246 { 00247 // advance pseudo random numbers 00248 z_ = ( 36969 * ( z_ & 0xffff ) + ( z_ >> 16 ) ) & 0xffffffff; 00249 w_ = ( 18000 * ( w_ & 0xffff ) + ( w_ >> 16 ) ) & 0xffffffff; 00250 00251 return ( (z_ << 16) + w_ ) & 0xffffffff; 00252 00253 /* 00254 unsigned int r = 0; 00255 00256 // read random value from recording 00257 if ( !tRecorder::PlaybackStrict( recordingSection, r ) ) 00258 { 00259 // not found. generate random value 00260 r = rand(); 00261 00262 // store it 00263 tRecorder::Record( recordingSection, r ); 00264 } 00265 00266 return r; 00267 */ 00268 }
int tReproducibleRandomizer::z_ [private] |
int tReproducibleRandomizer::w_ [private] |