forked from LeHulk1/RandoBlazer
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRandom.cpp
More file actions
31 lines (24 loc) · 717 Bytes
/
Copy pathRandom.cpp
File metadata and controls
31 lines (24 loc) · 717 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
#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});
}
}