#include "Define.h"
#include "Duration.h"
#include <limits>
Go to the source code of this file.
◆ frand()
Definition at line 55 of file Random.cpp.
56{
58 std::uniform_real_distribution<float> urd(min, max);
60}
static RandomEngine engine
◆ irand()
Definition at line 35 of file Random.cpp.
36{
38 std::uniform_int_distribution<int32> uid(min, max);
40}
◆ rand32()
Definition at line 70 of file Random.cpp.
71{
73}
static SFMTRand * GetRng()
◆ rand_chance()
Definition at line 81 of file Random.cpp.
82{
83 std::uniform_real_distribution<double> urd(0.0, 100.0);
85}
◆ rand_norm()
Definition at line 75 of file Random.cpp.
76{
77 std::uniform_real_distribution<double> urd;
79}
◆ randtime()
Definition at line 62 of file Random.cpp.
63{
64 long long diff = max.count() - min.count();
66 ASSERT(diff <= 0xFFFFFFFF);
68}
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
uint32 urand(uint32 min, uint32 max)
◆ roll_chance_f()
bool roll_chance_f |
( |
float |
chance | ) |
|
|
inline |
Definition at line 53 of file Random.h.
54{
56}
TC_COMMON_API double rand_chance()
◆ roll_chance_i()
bool roll_chance_i |
( |
int |
chance | ) |
|
|
inline |
Definition at line 59 of file Random.h.
60{
61 return chance >
irand(0, 99);
62}
TC_COMMON_API int32 irand(int32 min, int32 max)
◆ urand()
Definition at line 42 of file Random.cpp.
43{
45 std::uniform_int_distribution<uint32> uid(min, max);
47}
◆ urandms()
Definition at line 49 of file Random.cpp.
50{
51 ASSERT(std::numeric_limits<uint32>::max() / Milliseconds::period::den >= max);
52 return urand(min * Milliseconds::period::den, max * Milliseconds::period::den);
53}
◆ urandweighted()
Definition at line 87 of file Random.cpp.
88{
89 std::discrete_distribution<uint32> dd(chances, chances + count);
91}