#include "Random.h"
#include "Errors.h"
#include "SFMTRand.h"
#include <memory>
#include <random>
Go to the source code of this file.
◆ frand()
float frand |
( |
float |
min, |
|
|
float |
max |
|
) |
| |
Definition at line 55 of file Random.cpp.
56{
58 std::uniform_real_distribution<float> urd(min, max);
60}
static RandomEngine engine
◆ GetRng()
Definition at line 27 of file Random.cpp.
28{
30 sfmtRand = std::make_unique<SFMTRand>();
31
33}
static thread_local std::unique_ptr< SFMTRand > sfmtRand
◆ 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)
◆ 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()
uint32 urandweighted |
( |
size_t |
count, |
|
|
double const * |
chances |
|
) |
| |
Definition at line 87 of file Random.cpp.
88{
89 std::discrete_distribution<uint32> dd(chances, chances + count);
91}
◆ engine
◆ sfmtRand
thread_local std::unique_ptr<SFMTRand> sfmtRand |
|
static |