-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrandommanager.cpp
More file actions
36 lines (29 loc) · 859 Bytes
/
randommanager.cpp
File metadata and controls
36 lines (29 loc) · 859 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
36
#include "randommanager.h"
using namespace std;
RandomManager::RandomManager(unsigned int basic_seed) :
seed(basic_seed), rngInt09(0,9), rngDouble01(0,1) {}
int RandomManager::RandomInt09(){
return rngInt09(seed);
}
double RandomManager::RandomDouble01() {
return rngDouble01(seed);
}
double RandomManager::RandomDouble(double lim) {
uniform_real_distribution<double> rngDouble(0,lim);
return rngDouble(seed);
}
Pos RandomManager::RandomPosition(){
uniform_int_distribution<int> rng_x(0, 7);
uniform_int_distribution<int> rng_y(0, 13);
int pos_x = rng_x(seed);
int pos_y = rng_y(seed);
return Pos(pos_x, pos_y);
}
pair<Pos, Pos> RandomManager::TwoRandomPosition(){
Pos first_pos = RandomPosition();
while (true) {
Pos second_pos = RandomPosition();
if (first_pos == second_pos) continue;
return make_pair(first_pos, second_pos);
}
}