30 using IsChar =
typename std::is_same<typename std::make_signed<Char>::type,
signed char>::type;
32 template <
class IntType>
34 public std::conditional<
35 IsChar<IntType>::value,
36 typename std::conditional<
37 std::is_signed<IntType>::value,
38 std::uniform_int_distribution<short>,
39 std::uniform_int_distribution<unsigned short>
41 std::uniform_int_distribution<IntType>
47 template <
class IntType>
56 template <
class RandomEngine>
68 template <
class SeedSeq>
77 template <
class IntType =
int>
78 IntType
RandInt(IntType a_Min, IntType a_Max)
82 (a_Max <= std::numeric_limits<IntType>::max()) &&
83 (a_Min >= std::numeric_limits<IntType>::min())
86 static_cast<IntType
>(a_Min),
87 static_cast<IntType
>(a_Max)
89 return static_cast<IntType
>(dist(
m_Engine));
97 template <
class IntType =
int>
100 ASSERT((a_Max >= 0) && (a_Max <= std::numeric_limits<IntType>::max()));
102 return static_cast<IntType
>(dist(
m_Engine));
110 template <
class IntType =
int>
114 return static_cast<IntType
>(dist(
m_Engine));
122 template <
class RealType =
float>
125 std::uniform_real_distribution<RealType> dist(a_Min, a_Max);
134 template <
class RealType =
float>
137 std::uniform_real_distribution<RealType> dist(RealType(0), a_Max);
146 template <
class RealType =
float>
149 std::uniform_real_distribution<RealType> dist;
160 std::bernoulli_distribution dist(a_TrueProbability);
190 std::random_device rd;
191 std::uniform_int_distribution<result_type> dist;
192 for (; first != last; ++first)
MTRand & GetRandomProvider()
Returns the current thread's random number source.
typename std::is_same< typename std::make_signed< Char >::type, signed char >::type IsChar
Aliases true_type if Char is any variant of char ignoring signed-ness.
UInt32 GetRandomSeed()
Returns a low quality seed.
typename cUniformImpl< IntType >::type cUniform
uniform_int_distribution<char> is undefined so this aliases a valid type.
Class to wrap any random engine to provide a more convenient interface.
cRandomWrapper()
Initialize with a low quality seed.
RandomEngine & Engine()
Returns a reference to the underlying random engine.
cRandomWrapper(SeedSeq &a_SeedSeq)
Initialize with a SeedSequence.
RealType RandReal()
Return a random RealType in the range [0, 1).
RealType RandReal(RealType a_Min, RealType a_Max)
Return a random RealType in the range [a_Min, a_Max).
IntType RandInt()
Return a random IntType in the range [0, std::numeric_limits<IntType>::max()].
IntType RandInt(IntType a_Max)
Return a random IntType in the range [0, a_Max].
RealType RandReal(RealType a_Max)
Return a random RealType in the range [0, a_Max).
IntType RandInt(IntType a_Min, IntType a_Max)
Return a random IntType in the range [a_Min, a_Max].
bool RandBool(double a_TrueProbability=0.5)
Return a random bool with the given probability of being true.
Utility to seed a random engine with maximal entropy from random_device.
std::random_device::result_type result_type
void generate(Itr first, Itr last)