SimulationCraft
SimulationCraft is a tool to explore combat mechanics in the popular MMO RPG World of Warcraft (tm).
rng::basic_rng_t< Engine > Struct Template Reference

Random number generator wrapper around an rng engine. More...

#include <rng.hpp>

Public Member Functions

 basic_rng_t (const basic_rng_t &)=delete
 
basic_rng_toperator= (const basic_rng_t &)=delete
 
const char * name () const
 Return engine name.
 
void seed (uint64_t s)
 Seed rng engine.
 
uint64_t reseed ()
 Reseed using current state.
 
void reset ()
 Reset any state. More...
 
double real ()
 Uniform distribution in range [0..1) More...
 
bool roll (double chance)
 Bernoulli Distribution.
 
double range (double min, double max)
 Uniform distribution in the range [min..max)
 
template<typename T , typename = std::enable_if_t<std::is_integral<T>::value>>
range (T min, T max)
 Uniform distribution in the range [min..max)
 
template<typename T , typename = std::enable_if_t<std::is_integral<T>::value>>
range (T max)
 Uniform distribution in the range [0..max)
 
double gauss (double mean, double stddev, bool truncate_low_end=false)
 Gaussian Distribution. More...
 
double exponential (double nu)
 Exponential Distribution.
 
double exgauss (double gauss_mean, double gauss_stddev, double exp_nu)
 Exponentially Modified Gaussian Distribution.
 
timespan_t range (timespan_t min, timespan_t max)
 Timespan uniform distribution in the range [min..max)
 
timespan_t gauss (timespan_t mean, timespan_t stddev)
 Timespan Gaussian Distribution.
 
timespan_t exgauss (timespan_t mean, timespan_t stddev, timespan_t nu)
 Timespan exponentially Modified Gaussian Distribution.
 

Detailed Description

template<typename Engine>
struct rng::basic_rng_t< Engine >

Random number generator wrapper around an rng engine.

Implements different distribution outputs ( uniform, gauss, etc. )

Member Function Documentation

◆ gauss()

template<typename Engine >
double rng::basic_rng_t< Engine >::gauss ( double  mean,
double  stddev,
bool  truncate_low_end = false 
)

Gaussian Distribution.

This code adapted from ftp://ftp.taygeta.com/pub/c/boxmuller.c Implements the Polar form of the Box-Muller Transformation

(c) Copyright 1994, Everett F. Carter Jr. Permission is granted by the author to use this software for any application provided this copyright notice is preserved.

◆ real()

template<typename Engine >
double rng::basic_rng_t< Engine >::real ( )
inline

Uniform distribution in range [0..1)

MAGIC! http://en.wikipedia.org/wiki/Double-precision_floating-point_format

◆ reset()

template<typename Engine >
void rng::basic_rng_t< Engine >::reset ( )

Reset any state.

Reset state.