simple_rng Class Reference

#include <random.hpp>

List of all members.

Public Member Functions

 simple_rng ()
 simple_rng (const config &cfg)
int get_random ()
 Get a new random number.
void seed_random (const unsigned call_count=0)
 Seeds the random pool.
void seed_random (const int seed, const unsigned call_count=0)
 Seeds the random pool.
void rotate_random ()
 Resets the random to the 0 calls and the seed to the random this way we stay in the same sequence but don't have a lot calls.
int get_random_seed () const
int get_random_calls () const

Private Member Functions

void random_next ()
 Sets the next random number in the pool.

Private Attributes

int random_seed_
 Initial seed for the pool.
int random_pool_
 State for the random pool.
unsigned random_calls_
 Number of time a random number is generated.


Detailed Description

Definition at line 56 of file random.hpp.


Constructor & Destructor Documentation

simple_rng::simple_rng (  ) 

Definition at line 131 of file random.cpp.

simple_rng::simple_rng ( const config cfg  ) 

Todo:
older savegames don't have random_seed stored, evaluate later whether default can be removed again. Look after branching 1.5.

Definition at line 137 of file random.cpp.


Member Function Documentation

int simple_rng::get_random (  ) 

Get a new random number.

Definition at line 146 of file random.cpp.

References random_calls_, random_next(), and random_pool_.

Referenced by unit::generate_gender(), unit::generate_traits(), and markov_generate_name().

void simple_rng::seed_random ( const unsigned  call_count = 0  ) 

Seeds the random pool.

Parameters:
call_count Upon loading we need to restore the state at saving so set the number of times a random number is generated for replays the orginal value is required.

Definition at line 161 of file random.cpp.

References random_seed_.

Referenced by game_state::game_state(), and mp::level_to_gamestate().

void simple_rng::seed_random ( const int  seed,
const unsigned  call_count = 0 
)

Seeds the random pool.

Parameters:
seed The initial value for the random engine.
call_count Upon loading we need to restore the state at saving so set the number of times a random number is generated for replays the orginal value is required.

Definition at line 172 of file random.cpp.

References random_calls_, random_next(), random_pool_, and random_seed_.

void simple_rng::rotate_random (  )  [inline]

Resets the random to the 0 calls and the seed to the random this way we stay in the same sequence but don't have a lot calls.

Used when moving to the next scenario.

Definition at line 73 of file random.hpp.

References random_calls_, random_pool_, and random_seed_.

Referenced by play_game().

int simple_rng::get_random_seed (  )  const [inline]

Definition at line 77 of file random.hpp.

References random_seed_.

Referenced by mp::connect::load_game(), and write_game().

int simple_rng::get_random_calls (  )  const [inline]

Definition at line 78 of file random.hpp.

References random_calls_.

Referenced by write_game().

void simple_rng::random_next (  )  [private]

Sets the next random number in the pool.

Definition at line 185 of file random.cpp.

References random_pool_.

Referenced by get_random(), and seed_random().


Member Data Documentation

int simple_rng::random_seed_ [private]

Initial seed for the pool.

Definition at line 82 of file random.hpp.

Referenced by get_random_seed(), rotate_random(), and seed_random().

int simple_rng::random_pool_ [private]

State for the random pool.

Definition at line 85 of file random.hpp.

Referenced by get_random(), random_next(), rotate_random(), and seed_random().

unsigned simple_rng::random_calls_ [private]

Number of time a random number is generated.

Definition at line 88 of file random.hpp.

Referenced by get_random(), get_random_calls(), rotate_random(), and seed_random().


The documentation for this class was generated from the following files:

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs