-
Notifications
You must be signed in to change notification settings - Fork 0
/
commuter.cpp
67 lines (48 loc) · 1.06 KB
/
commuter.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <random>
#include "commuter.h"
Commuter::Commuter(){
id = -1;
V = -1;
Ta = -1;
Tb = -1;
tauAMax = -1;
tauB = -1;
Uap = -1;
Ub = -1;
}
Commuter::Commuter(int inID, double inV, int inTa, int inTb, double inTauB){
id = inID;
V = inV;
Ta = inTa;
Tb = inTb;
tauB = inTauB;
Uap = -Ta;
Ub = -Tb-(tauB/V);
tauAMax = -1*V*(Ub+Ta);
}
bool Commuter::UapCheck(){
if( Uap < Ub ){
return false;
}
return true;
}
void Commuter::reroll(int i){
// randomize V
V = (20 + ( std::rand() % ( 80 - 20 + 1 ) ))/100.0;
// randomize Tb
Tb = 0;
if(i != 37){
Tb = 1 + ( std::rand() % ( 3*(37-i) - 1 + 1 ) );
}
// radomize Ta
Ta = 37;
if(i != 37){
Ta = (i+1) + ( std::rand() % ( 37 - (i+1) + 1 ) );
}
Ta = 2*(Ta-i);
// randomize tauB
tauB = (0 + ( std::rand() % ( 500 - 0 + 1 ) ))/100.0;
Uap = -Ta;
Ub = -Tb-(tauB/V);
tauAMax = -1*V*(Ub+Ta);
}