tReproducibleRandomizer Class Reference

Reproducible random generator. More...

#include <tRandom.h>

Inheritance diagram for tReproducibleRandomizer:

Inheritance graph
[legend]
Collaboration diagram for tReproducibleRandomizer:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 tReproducibleRandomizer ()
 default constructor
 ~tReproducibleRandomizer ()
 destructor

Static Public Member Functions

static tReproducibleRandomizerGetInstance ()
 returns the standard reproducible randomizer

Private Member Functions

virtual unsigned int GetRawRand ()
 returns a raw random number

Private Attributes

int z_
int w_


Detailed Description

Reproducible random generator.

Definition at line 60 of file tRandom.h.


Constructor & Destructor Documentation

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 }

Here is the call graph for this function:

tReproducibleRandomizer::~tReproducibleRandomizer ( void   ) 

destructor

Definition at line 215 of file tRandom.cpp.

00216 {
00217 }


Member Function Documentation

tReproducibleRandomizer & tReproducibleRandomizer::GetInstance ( void   )  [static]

returns the standard reproducible randomizer

Returns:
the default 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 }

Here is the caller graph for this function:

unsigned int tReproducibleRandomizer::GetRawRand ( void   )  [private, virtual]

returns a raw random number

Returns:
raw random value between 0 and randMax_ todo use own, fixed random algorithm so the random values don't have to be stored

Reimplemented from tRandomizer.

Definition at line 245 of file tRandom.cpp.

References w_, and z_.

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 }


Member Data Documentation

int tReproducibleRandomizer::z_ [private]

Definition at line 70 of file tRandom.h.

Referenced by GetRawRand(), and tReproducibleRandomizer().

int tReproducibleRandomizer::w_ [private]

Definition at line 70 of file tRandom.h.

Referenced by GetRawRand(), and tReproducibleRandomizer().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:58:59 2008 for Armagetron Advanced by  doxygen 1.5.4