[Add] Using confidence intervals now.
This commit is contained in:
parent
40982ef496
commit
a8dd594369
@ -302,8 +302,7 @@ static double econ_calcSysI(unsigned int dt, StarSystem* sys, int price) {
|
||||
*/
|
||||
prodfactor = planet->cur_prodfactor;
|
||||
/* Add a variability factor based on the gaussian distribution. */
|
||||
prodfactor += ECON_PROD_VAR *
|
||||
NormalInverse(RNGF()*0.90 + 0.05)*ddt;
|
||||
prodfactor += ECON_PROD_VAR * RNG_2SIGMA() * ddt;
|
||||
/* Add a tendency to return to the planets base production. */
|
||||
prodfactor -= ECON_PROD_VAR *
|
||||
(planet->cur_prodfactor - prodfactor)*ddt;
|
||||
|
27
src/rng.h
27
src/rng.h
@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @def RNG(L,H)
|
||||
*
|
||||
* @brief Get a random number between L and H (L <= RNG <= H).
|
||||
*
|
||||
* If L is bigger than H it inverts the roles.
|
||||
@ -10,8 +8,6 @@
|
||||
#define RNG(L,H) (((L)>(H)) ? RNG_SANE((H), (L)) : RNG_SANE((L),(H)))
|
||||
|
||||
/**
|
||||
* @def RNG_SANE(L,H)
|
||||
*
|
||||
* @brief Get a number between L and H (L <= RNG <= H).
|
||||
*
|
||||
* Result unspecified if L is bigger than H.
|
||||
@ -19,12 +15,31 @@
|
||||
#define RNG_SANE(L,H) ((int)L + (int)((double)(H-L+1) * randfp())) /* L <= RNG <= H */
|
||||
|
||||
/**
|
||||
* @def RNGF()
|
||||
*
|
||||
* @brief Get a random float between 0 and 1 (0. <= RNGF <= 1.).
|
||||
*/
|
||||
#define RNGF() (randfp()) /* 0. <= RNGF <= 1. */
|
||||
|
||||
/**
|
||||
* @brief Get a random mu within one-sigma (-1 to 1).
|
||||
*
|
||||
* 63% Confidence interval.
|
||||
*/
|
||||
#define RNG_1SIGMA() NormalInverse(0.158 + RNGF()*(1.-0.341*2.))
|
||||
|
||||
/**
|
||||
* @brief Get a random mu withing two-sigma(-2 to 2)
|
||||
*
|
||||
* 95% confidence interval.
|
||||
*/
|
||||
#define RNG_2SIGMA() NormalInverse(0.021 + RNGF()*(1.-0.021*2.))
|
||||
|
||||
/**
|
||||
* @brief Get a random mu within three sigma (-3 to 3).
|
||||
*
|
||||
* 99.8% Confidence interval.
|
||||
*/
|
||||
#define RNG_3SIGMA() NormalInverse(0.001 + RNGF()*(1.-0.001*2.))
|
||||
|
||||
/* Init. */
|
||||
void rng_init(void);
|
||||
|
||||
|
@ -462,9 +462,9 @@ void space_update(const double dt) {
|
||||
interference_timer -= dt;
|
||||
if(interference_timer < 0.) {
|
||||
interference_timer += (1000. - cur_system->interference) / 1000. *
|
||||
(3. + NormalInverse(0.25 + 0.95*RNGF()));
|
||||
(3. + RNG_2SIGMA());
|
||||
interference_target = cur_system->interference/1000. * 2. *
|
||||
(1. + NormalInverse(0.25 + 0.95*RNGF()));
|
||||
(1. + RNG_2SIGMA());
|
||||
}
|
||||
|
||||
/* Head towards target. */
|
||||
|
@ -775,10 +775,8 @@ static Weapon* weapon_create(const Outfit* outfit, const double dir, const Vec2*
|
||||
} else /* Fire straight. */
|
||||
rdir = dir;
|
||||
|
||||
rdir += NormalInverse(RNGF()*0.9 + 0.05) /* Get rid of extreme values. */
|
||||
* outfit->u.blt.accuracy/2. * 1./180.0*M_PI;
|
||||
|
||||
if((rdir > 2.*M_PI) || (rdir < 0.)) rdir = fmod(rdir, 2.*M_PI);
|
||||
rdir += RNG_2SIGMA() * outfit->u.blt.accuracy/2. * 1./180.*M_PI;
|
||||
if((rdir > 2.*M_PI) || (rdir < 0.)) rdir = fmod(rdir, 2.*M_PI);
|
||||
|
||||
mass = 1; /* Lasers are presumed to have unitory mass. */
|
||||
vectcpy(&v, vel);
|
||||
|
Loading…
Reference in New Issue
Block a user