Random.cpp 396 B

1234567891011121314151617181920
  1. #include "Random.h"
  2. PseudoRandom::PseudoRandom(): generator(rd()), boolDistribution(0.5), doubleDistribution(0,1)
  3. {
  4. }
  5. bool PseudoRandom::randomBool()
  6. {
  7. return boolDistribution(generator);
  8. }
  9. double PseudoRandom::doubleRandom()
  10. {
  11. return doubleDistribution(generator);
  12. }
  13. int PseudoRandom::randomIntegerInRange(int min, int max)
  14. {
  15. return std::uniform_int_distribution(min,max-1)(generator);
  16. }