3 #include "ge211_forward.h" 12 template <
class T,
class Enable =
void>
16 std::is_integral<T>::value || std::is_floating_point<T>::value,
17 "Random::between: only works on built-in numeric types" 21 template <
class T,
class Enable =
void>
24 std::is_integral<T>::value || std::is_floating_point<T>::value,
25 "Random::up_to: only works on built-in numeric types" 30 struct Between<T,
std::enable_if_t<std::is_integral<T>::value>>
31 : std::uniform_int_distribution<T>
33 using std::uniform_int_distribution<T>::uniform_int_distribution;
37 struct Between<T,
std::enable_if_t<std::is_floating_point<T>::value>>
38 : std::uniform_real_distribution<T>
40 using std::uniform_real_distribution<T>::uniform_real_distribution;
44 struct Up_to<T,
std::enable_if_t<std::is_integral<T>::value>>
47 explicit Up_to(T max) : Between<T>{0, max - 1}
52 struct Up_to<T,
std::enable_if_t<std::is_floating_point<T>::value>>
55 explicit Up_to(T max) : Between<T>{0, max}
79 return detail::Up_to<T>{max}(generator_);
97 return detail::Between<T>{min, max}(generator_);
115 std::mt19937_64 generator_;
T up_to(T max)
Returns a random T between 0 (inclusive) and max (exclusive).
This is the abstract base class for deriving games.
The game engine namespace.
bool random_bool(double ptrue=0.5)
Returns a random bool that is true with probability ptrue.
A pseudo-random number generator.
T between(T min, T max)
Returns a random T between min and max.