Blackcomb  prealpha
Engine-ish
RNG.h
1 #ifndef BLACKCOMB_RNG_H
2 #define BLACKCOMB_RNG_H
3 
4 #include <random>
5 
6 namespace blackcomb::misc {
10  class RNG {
11  public:
12  RNG();
13  RNG(unsigned long seed);
14  template <typename T> T randRange(T min, T max);
15  template <typename T> T random();
16  template <typename T> T randInt(T min, T max);
17  template <typename T> T choice(std::vector<T> vec);
18  void setSeed(unsigned long seed);
19  private:
20  std::random_device rd;
21  std::mt19937 generator;
22  };
23 }
24 
25 #endif //BLACKCOMB_RNG_H
T choice(std::vector< T > vec)
Selects a random element from a vector.
Definition: RNG.cpp:41
void setSeed(unsigned long seed)
Sets the random number generator&#39;s seed.
Definition: RNG.cpp:48
T randInt(T min, T max)
Generates a random integer in a range from min to max, inclusive.
Definition: RNG.cpp:32
T randRange(T min, T max)
Generates a random number in a range from min to max, inclusive.
Definition: RNG.cpp:13
Definition: BlackcombException.h:6
T random()
Generates a random real number from zero to one, inclusive.
Definition: RNG.cpp:23
A wrapper for C++&#39;s random number generator featuring a very original interface.
Definition: RNG.h:10