Random Class Reference

#include <Random.h>

Collaboration diagram for Random:

Collaboration graph
[legend]

Public Member Functions

virtual ~Random ()
 Destructor.

Static Public Member Functions

static long int value ()
 Generate a pseudo-random value.
static void destroy ()
 Destroy the instance of Random.
static long int getMaxVal ()
 Accessor to the max value Random can generated.
static long int getMinVal ()
 Accessor to the min value Random can generated.

Protected Member Functions

 Random ()
 Constructor.

Static Protected Attributes

static Random_instance = NULL

Detailed Description

< A pseudo-random number generator

Definition at line 31 of file Random.h.


Member Function Documentation

long int Random::value (  )  [static]

Generate a pseudo-random value.

Returns:
the generated value

Definition at line 36 of file Random.cpp.

References _instance, and Random().

Referenced by GeneticReplication::createWorshiper(), GeneticCode::crossover(), GeneticCode::GeneticCode(), HeuristicReplication::getNewWorshipers(), GeneticReplication::getNewWorshipers(), GeneticCode::mutate(), Behaviour::randomMove(), UntilVictoryFight::resolve(), and World::World().

00036                        {
00037   if(_instance == NULL) {
00038     _instance = new Random();
00039   }
00040 
00041   return rand();
00042 }

Here is the call graph for this function:

Here is the caller graph for this function:

long int Random::getMaxVal (  )  [static]

Accessor to the max value Random can generated.

Returns:
the max value generable

Definition at line 51 of file Random.cpp.

00051                            {
00052   return RAND_MAX;
00053 }

long int Random::getMinVal (  )  [static]

Accessor to the min value Random can generated.

Returns:
the min value generable

Definition at line 55 of file Random.cpp.

00055                            {
00056   return 0;
00057 }


Field Documentation

Random * Random::_instance = NULL [static, protected]

The instance of Random (use of singleton design pattern)

Definition at line 36 of file Random.h.

Referenced by destroy(), and value().


The documentation for this class was generated from the following files:
Generated on Sat Feb 2 22:23:17 2008 for Teapot Colony Wars by  doxygen 1.5.4