-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRandom.cpp
More file actions
35 lines (27 loc) · 784 Bytes
/
Random.cpp
File metadata and controls
35 lines (27 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "Random.h"
#include <random>
#include <boost/random/uniform_int_distribution.hpp>
static std::mt19937 gen;
namespace Random {
int RandomInit(unsigned int seed) {
if (seed == 0) {
std::random_device rd;
seed = rd();
gen.seed(seed);
}
else {
gen.seed(seed);
}
return seed;
}
int RandomInteger(int Range) {
return RandomIntegerRange(0, Range - 1);
}
int RandomIntegerRange(int LowerBound, int UpperBound) {
static boost::random::uniform_int_distribution<int> dis;
return dis(gen, boost::random::uniform_int_distribution<int>::param_type{LowerBound, UpperBound});
}
void discard(unsigned long z) {
gen.discard(z);
}
}