![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <random>#include <stdint.h>
Include dependency graph for rand.h:Go to the source code of this file.
Macros | |
| #define | fc_rand(_size) fc_rand_debug((_size), "fc_rand", __LINE__, __FILE__) |
| #define | fc_randomly(_seed, _size) fc_randomly_debug((_seed), (_size), "fc_randomly", __LINE__, __FILE__) |
Functions | |
| std::uint_fast32_t | fc_rand_debug (std::uint_fast32_t size, const char *called_as, int line, const char *file) |
| Returns a new random value from the sequence, in the interval 0 to (size-1) inclusive, and updates global state for next call. More... | |
| void | fc_srand (std::uint_fast32_t seed) |
| Initialize the generator; see comment at top of file. More... | |
| void | fc_rand_seed (std::mt19937 &gen) |
| Seeds the given generator with a random value. More... | |
| bool | fc_rand_is_init () |
| Return whether the current state has been initialized. More... | |
| void | fc_rand_set_init (bool init) |
| Sets whether the current state has been initialized. More... | |
| std::mt19937 & | fc_rand_state () |
| Returns a reference to the current random generator state; eg for save/restore. More... | |
| void | fc_rand_set_state (const std::mt19937 &state) |
| Replace current rand_state with user-supplied; eg for save/restore. More... | |
| std::uint_fast32_t | fc_randomly_debug (std::uint_fast32_t seed, std::uint_fast32_t size, const char *called_as, int line, const char *file) |
| Local pseudo-random function for repeatedly reaching the same result, instead of fc_rand(). More... | |
| #define fc_rand | ( | _size | ) | fc_rand_debug((_size), "fc_rand", __LINE__, __FILE__) |
| #define fc_randomly | ( | _seed, | |
| _size | |||
| ) | fc_randomly_debug((_seed), (_size), "fc_randomly", __LINE__, __FILE__) |
| std::uint_fast32_t fc_rand_debug | ( | std::uint_fast32_t | size, |
| const char * | called_as, | ||
| int | line, | ||
| const char * | file | ||
| ) |
| bool fc_rand_is_init | ( | ) |
| void fc_rand_seed | ( | std::mt19937 & | gen | ) |
Seeds the given generator with a random value.
Definition at line 113 of file rand.cpp.
Referenced by init_game_seed(), map_generate(), and sg_load_random().
| void fc_rand_set_init | ( | bool | init | ) |
Sets whether the current state has been initialized.
Definition at line 83 of file rand.cpp.
Referenced by fc_rand_set_state(), fc_srand(), init_game_seed(), and freeciv::server::shut_game_down().
| void fc_rand_set_state | ( | const std::mt19937 & | state | ) |
Replace current rand_state with user-supplied; eg for save/restore.
Caller should take care to set state.is_init beforehand if necessary.
Definition at line 129 of file rand.cpp.
Referenced by map_generate(), sg_load_random(), and sg_load_sanitycheck().
| std::mt19937& fc_rand_state | ( | ) |
Returns a reference to the current random generator state; eg for save/restore.
Definition at line 123 of file rand.cpp.
Referenced by genlist_shuffle(), init_game_seed(), loaddata_new(), map_generate(), sg_load_random(), and sg_save_random().
| std::uint_fast32_t fc_randomly_debug | ( | std::uint_fast32_t | seed, |
| std::uint_fast32_t | size, | ||
| const char * | called_as, | ||
| int | line, | ||
| const char * | file | ||
| ) |
| void fc_srand | ( | std::uint_fast32_t | seed | ) |
Initialize the generator; see comment at top of file.
Definition at line 69 of file rand.cpp.
Referenced by client_main(), fcmp_init(), init_game_seed(), and map_generate().