class
#include <bn_seed_random.h>
seed_random Deterministic random number generator with a public, configurable seed.
See https:/
Constructors, destructors, conversion operators
- seed_random() defaulted constexpr
- Default constructor.
- seed_random(unsigned seed) explicit constexpr
- Constructor.
Public functions
- auto seed() const -> unsigned constexpr
- Returns the value of the seed used to generate random numbers.
- void set_seed(unsigned seed) constexpr
- Sets the value of the seed used to generate random numbers.
- auto get() -> unsigned constexpr
- Returns a random unsigned integer greater or equal than 0, updating its seed in the process.
- auto get_bool() -> bool constexpr
- Returns a random boolean, updating its internal seed in the process.
- auto get_int() -> int constexpr
- Returns a random signed integer greater or equal than 0, updating its seed in the process.
- auto get_fixed() -> fixed constexpr
- Returns a random bn::
fixed greater or equal than 0, updating its seed in the process. - auto get_int(int limit) -> int constexpr
- Returns a random signed integer in the range [0..limit), updating its internal seed in the process.
- auto get_fixed(fixed limit) -> fixed constexpr
- Returns a random bn::
fixed in the range [0..limit), updating its internal seed in the process. - auto get_int(int minimum, int limit) -> int constexpr
- Returns a random signed integer in the range [minimum..limit), updating its internal seed in the process.
- auto get_fixed(fixed minimum, fixed limit) -> fixed constexpr
- Returns a random bn::
fixed in the range [minimum..limit), updating its internal seed in the process. - auto get_unbiased_int(int limit) -> int constexpr
- Returns a random signed integer in the range [0..limit), updating its internal seed in the process.
- auto get_unbiased_fixed(fixed limit) -> fixed constexpr
- Returns a random bn::
fixed in the range [0..limit), updating its internal seed in the process. - auto get_unbiased_int(int minimum, int limit) -> int constexpr
- Returns a random signed integer in the range [minimum..limit), updating its internal seed in the process.
- auto get_unbiased_fixed(fixed minimum, fixed limit) -> fixed constexpr
- Returns a random bn::
fixed in the range [minimum..limit), updating its internal seed in the process. - void update() constexpr
- Updates the value of the seed.
Function documentation
bn:: seed_random:: seed_random(unsigned seed) explicit constexpr
Constructor.
Parameters | |
---|---|
seed | Initial value of the seed used to generate random numbers. |
int bn:: seed_random:: get_int(int limit) constexpr
Returns a random signed integer in the range [0..limit), updating its internal seed in the process.
Parameters | |
---|---|
limit | Returned value is lower than this value. |
Returns | Random signed integer in the range [0..limit). |
It's possible that the output will be biased towards smaller numbers due to modulo bias.
seed_random::
fixed bn:: seed_random:: get_fixed(fixed limit) constexpr
Returns a random bn::
Parameters | |
---|---|
limit | Returned value is lower than this value. |
Returns | Random bn:: |
It's possible that the output will be biased towards smaller numbers due to modulo bias.
seed_random::
int bn:: seed_random:: get_int(int minimum,
int limit) constexpr
Returns a random signed integer in the range [minimum..limit), updating its internal seed in the process.
Parameters | |
---|---|
minimum | Returned value is greater or equal than this value. |
limit | Returned value is lower than this value. |
Returns | Random signed integer in the range [minimum..limit). |
It's possible that the output will be biased towards smaller numbers due to modulo bias.
seed_random::
fixed bn:: seed_random:: get_fixed(fixed minimum,
fixed limit) constexpr
Returns a random bn::
Parameters | |
---|---|
minimum | Returned value is greater or equal than this value. |
limit | Returned value is lower than this value. |
Returns | Random bn:: |
It's possible that the output will be biased towards smaller numbers due to modulo bias.
seed_random::
int bn:: seed_random:: get_unbiased_int(int limit) constexpr
Returns a random signed integer in the range [0..limit), updating its internal seed in the process.
Parameters | |
---|---|
limit | Returned value is lower than this value. |
Returns | Random signed integer in the range [0..limit). |
This implementation avoids modulo bias, so it's less likely that the output will be biased towards smaller numbers.
fixed bn:: seed_random:: get_unbiased_fixed(fixed limit) constexpr
Returns a random bn::
Parameters | |
---|---|
limit | Returned value is lower than this value. |
Returns | Random bn:: |
This implementation avoids modulo bias, so it's less likely that the output will be biased towards smaller numbers.
int bn:: seed_random:: get_unbiased_int(int minimum,
int limit) constexpr
Returns a random signed integer in the range [minimum..limit), updating its internal seed in the process.
Parameters | |
---|---|
minimum | Returned value is greater or equal than this value. |
limit | Returned value is lower than this value. |
Returns | Random signed integer in the range [minimum..limit). |
This implementation avoids modulo bias, so it's less likely that the output will be biased towards smaller numbers.
fixed bn:: seed_random:: get_unbiased_fixed(fixed minimum,
fixed limit) constexpr
Returns a random bn::
Parameters | |
---|---|
minimum | Returned value is greater or equal than this value. |
limit | Returned value is lower than this value. |
Returns | Random bn:: |
This implementation avoids modulo bias, so it's less likely that the output will be biased towards smaller numbers.