30 lines
641 B
C++
30 lines
641 B
C++
#ifndef RANDOM_Random_RandomGenerator_H
|
|
#define RANDOM_Random_RandomGenerator_H
|
|
|
|
#include <random>
|
|
#include <chrono>
|
|
|
|
#ifdef USE_FIXED_SEED
|
|
#define RANDOM_SEED 1234
|
|
#else
|
|
#define RANDOM_SEED ( std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1) )
|
|
#endif
|
|
|
|
namespace Random {
|
|
|
|
class RandomGenerator : public std::minstd_rand {
|
|
|
|
public:
|
|
|
|
/** ctor with default seed */
|
|
RandomGenerator() : std::minstd_rand(RANDOM_SEED) {;}
|
|
|
|
/** ctor with custom seed */
|
|
RandomGenerator(result_type) : std::minstd_rand(RANDOM_SEED) {;}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // RANDOM_Random_RandomGenerator_H
|