19 #include <boost/random/random_device.hpp>
26 #define DBG_RND LOG_STREAM(debug, log_random)
27 #define LOG_RND LOG_STREAM(info, log_random)
28 #define WRN_RND LOG_STREAM(warn, log_random)
29 #define ERR_RND LOG_STREAM(err, log_random)
31 static_assert(std::numeric_limits<double>::is_iec559,
"Floating point representation is not IEEE 754-compliant");
44 boost::random_device entropy_source;
45 gen_.seed(entropy_source());
75 static rng* def =
new rng_default();
108 return static_cast<int> (
next_random() % (
static_cast<uint32_t
>(max)+1));
115 double floating_point_number;
123 number.integer |=
static_cast<uint64_t
>(1023) << 52;
128 number.integer |=
static_cast<uint64_t
>(
next_random()) << (52 - 32);
133 return number.floating_point_number - 1.0;
138 assert(probability >= 0.0 && probability <= 1.0);
this class does not give synced random results derived classes might do.
unsigned int get_random_calls() const
Provides the number of random calls to the rng in this context.
uint32_t next_random()
Provides the next random draw.
static rng & default_instance()
virtual uint32_t next_random_impl()=0
unsigned int random_calls_
bool get_random_bool(double probability)
This helper method returns true with the probability supplied as a parameter.
double get_random_double()
This helper method returns a floating-point number in the range [0,1[.
int get_random_int_in_range_zero_to(int max)
Does the hard work of get_random_int.
Standard logging facilities (interface).
rng * generator
This generator is automatically synced during synced context.
static lg::log_domain log_random("random")