OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rng.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_COMPONENTS_MISC_RNG_H
2 #define OPENMW_COMPONENTS_MISC_RNG_H
3 
4 #include <cassert>
5 #include <random>
6 
7 namespace Misc
8 {
9 
10 /*
11  Provides central implementation of the RNG logic
12 */
13 class Rng
14 {
15 public:
16 
18  static std::mt19937 generator;
19 
21  static void init();
22 
24  static float rollProbability();
25 
27  static float rollClosedProbability();
28 
30  static int rollDice(int max);
31 
33  static int roll0to99() { return rollDice(100); }
34 };
35 
36 }
37 
38 #endif
static void init()
seed the RNG
Definition: rng.cpp:11
static float rollClosedProbability()
return value in range [0.0f, 1.0f] <- note closed upper range.
Definition: rng.cpp:21
static int rollDice(int max)
return value in range [0, max) <- note open upper range.
Definition: rng.cpp:26
static int roll0to99()
return value in range [0, 99]
Definition: rng.hpp:33
static float rollProbability()
return value in range [0.0f, 1.0f) <- note open upper range.
Definition: rng.cpp:16
Definition: rng.hpp:13
static std::mt19937 generator
create a RNG
Definition: rng.hpp:18