forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dispersion.cpp
38 lines (34 loc) · 811 Bytes
/
dispersion.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
#include "dispersion.h"
#include "rng.h"
double dispersion_sources::roll() const
{
double this_roll = 0.0;
for( const double &source : linear_sources ) {
this_roll += rng_float( 0.0, source );
}
for( const double &source : normal_sources ) {
this_roll += rng_normal( source );
}
for( const double &source : multipliers ) {
this_roll *= source;
}
return this_roll;
}
double dispersion_sources::max() const
{
double sum = 0.0;
for( const double &source : linear_sources ) {
sum += source;
}
for( const double &source : normal_sources ) {
sum += source;
}
for( const double &source : multipliers ) {
sum *= source;
}
return sum;
}
double dispersion_sources::avg() const
{
return max() / 2.0;
}