2021-03-02 04:08:10 +00:00
|
|
|
//
|
|
|
|
// Created by SeanOMik on 7/6/2020.
|
|
|
|
// Github: https://github.com/SeanOMik
|
|
|
|
// Email: seanomik@gmail.com
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef SIMPLEENGINE_RANDOM_H
|
|
|
|
#define SIMPLEENGINE_RANDOM_H
|
|
|
|
|
|
|
|
#include <limits>
|
2021-03-13 03:27:45 +00:00
|
|
|
#include <random>
|
2021-03-02 04:08:10 +00:00
|
|
|
namespace simpleengine {
|
2021-03-13 03:27:45 +00:00
|
|
|
template<typename T, class RandomDevice = std::random_device, class Generator = std::mt19937>
|
|
|
|
class Random {
|
|
|
|
private:
|
|
|
|
RandomDevice rd;
|
|
|
|
Generator gen;
|
|
|
|
public:
|
|
|
|
Random() {
|
|
|
|
this->gen = Generator(rd());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Dist = std::uniform_int_distribution<>>
|
|
|
|
T NextInRange(T min, T max) {
|
|
|
|
Dist dist(min, max);
|
|
|
|
|
|
|
|
return dist(gen);
|
|
|
|
}
|
|
|
|
};
|
2021-03-02 04:08:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif //SIMPLEENGINE_RANDOM_H
|