From aa19a3afb0b94e8b5fe055eeb38b1fb2ee1a67b0 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 19 Oct 2014 14:10:18 +0100 Subject: Migrated random generators to std::random --- src/FastRandom.h | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'src/FastRandom.h') diff --git a/src/FastRandom.h b/src/FastRandom.h index cebebad96..37d7f6eef 100644 --- a/src/FastRandom.h +++ b/src/FastRandom.h @@ -22,6 +22,7 @@ salts, the values they get will be different. #pragma once +#include @@ -30,6 +31,7 @@ salts, the values they get will be different. class cFastRandom { public: + cFastRandom(void); /// Returns a random int in the range [0 .. a_Range - 1]; a_Range must be less than 1M @@ -49,15 +51,33 @@ public: /** Returns a random int in the range [a_Begin .. a_End] */ int GenerateRandomInteger(int a_Begin, int a_End); - -protected: - int m_Seed; - int m_Counter; - - /// Counter that is used to initialize the seed, incremented for each object created - static int m_SeedCounter; -} ; +private: + + std::minstd_rand m_LinearRand; + std::uniform_int_distribution<> m_IntDistribution; + std::uniform_real_distribution m_FloatDistribution; +}; + + + + + +class MTRand +{ +public: + + MTRand(void); + + int randInt(int a_Range); + + int randInt(void); + double rand(double a_Range); +private: + std::mt19937 m_MersenneRand; + std::uniform_int_distribution<> m_IntDistribution; + std::uniform_real_distribution<> m_DoubleDistribution; +}; \ No newline at end of file -- cgit v1.2.3 From d0766fcea800db94941f46b3ef7449d91e50f554 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 21 Oct 2014 14:21:08 +0100 Subject: Missing EOL. --- src/FastRandom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/FastRandom.h') diff --git a/src/FastRandom.h b/src/FastRandom.h index 37d7f6eef..7eecc698a 100644 --- a/src/FastRandom.h +++ b/src/FastRandom.h @@ -80,4 +80,4 @@ private: std::mt19937 m_MersenneRand; std::uniform_int_distribution<> m_IntDistribution; std::uniform_real_distribution<> m_DoubleDistribution; -}; \ No newline at end of file +}; -- cgit v1.2.3