Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Rand {
- private:
- std::unique_ptr<std::mt19937> _mt;
- std::random_device _rd;
- public:
- Rand() {
- _mt = std::make_unique<std::mt19937>(_rd());
- }
- std::mt19937 & get() { return *_mt.get(); }
- template<typename T>
- T gen(T from, T to) {
- std::uniform_int_distribution<T> d(from, to);
- return d(get());
- }
- template<typename T>
- void enumgen(T & type) {
- std::uniform_int_distribution<i32> d((i32)T::None + 1, (i32)T::Max - 1);
- type = (T)d(get());
- }
- bool prob(float num) {
- std::bernoulli_distribution d(num);
- return d(get());
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement