Public Member Functions | Private Member Functions | Private Attributes

rand_rng::simple_rng Class Reference

#include <simple_rng.hpp>

List of all members.

Public Member Functions

 simple_rng ()
 simple_rng (const config &cfg)
int get_next_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.
unsigned random_pool_
 State for the random pool (modulo arithmetic).
unsigned random_calls_
 Number of time a random number is generated.

Detailed Description

Definition at line 25 of file simple_rng.hpp.


Constructor & Destructor Documentation

rand_rng::simple_rng::simple_rng (  ) 

Definition at line 244 of file random.cpp.

rand_rng::simple_rng::simple_rng ( const config cfg  ) 

Definition at line 251 of file random.cpp.


Member Function Documentation

int rand_rng::simple_rng::get_next_random (  ) 

Get a new random number.

Definition at line 258 of file random.cpp.

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

Referenced by generate_gender(), unit::generate_traits(), rand_rng::rng::get_random_private(), markov_generate_name(), unstore_unit_advance_choice::random_choice(), and WML_HANDLER_FUNCTION().

Here is the call graph for this function:

Here is the caller graph for this function:

int rand_rng::simple_rng::get_random_calls (  )  const [inline]

Definition at line 63 of file simple_rng.hpp.

References random_calls_.

Referenced by game_state::write_config(), and game_state::write_snapshot().

Here is the caller graph for this function:

int rand_rng::simple_rng::get_random_seed (  )  const [inline]

Definition at line 62 of file simple_rng.hpp.

References random_seed_.

Referenced by mp::connect::load_game(), game_state::write_config(), and game_state::write_snapshot().

Here is the caller graph for this function:

void rand_rng::simple_rng::random_next (  )  [private]

Sets the next random number in the pool.

Definition at line 292 of file random.cpp.

References random_pool_.

Referenced by get_next_random(), and seed_random().

Here is the caller graph for this function:

void rand_rng::simple_rng::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.

Used when moving to the next scenario.

Definition at line 274 of file random.cpp.

References random_calls_, random_pool_, and random_seed_.

Referenced by play_game().

Here is the caller graph for this function:

void rand_rng::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 280 of file random.cpp.

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

Here is the call graph for this function:

void rand_rng::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 269 of file random.cpp.

References random_seed_.

Referenced by game_state::game_state(), savegame::loadgame::set_gamestate(), and rand_rng::rng::set_seed().

Here is the caller graph for this function:


Member Data Documentation

Number of time a random number is generated.

Definition at line 73 of file simple_rng.hpp.

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

State for the random pool (modulo arithmetic).

Definition at line 70 of file simple_rng.hpp.

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

Initial seed for the pool.

Definition at line 67 of file simple_rng.hpp.

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


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:25:28 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs