diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-10-19 15:10:18 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-10-19 15:10:18 +0200 |
commit | aa19a3afb0b94e8b5fe055eeb38b1fb2ee1a67b0 (patch) | |
tree | f9b31400ccb64fb6c30af41952ba854cf246ff54 /src/FastRandom.h | |
parent | Merge branch 'master' of https://github.com/mc-server/MCServer (diff) | |
download | cuberite-aa19a3afb0b94e8b5fe055eeb38b1fb2ee1a67b0.tar cuberite-aa19a3afb0b94e8b5fe055eeb38b1fb2ee1a67b0.tar.gz cuberite-aa19a3afb0b94e8b5fe055eeb38b1fb2ee1a67b0.tar.bz2 cuberite-aa19a3afb0b94e8b5fe055eeb38b1fb2ee1a67b0.tar.lz cuberite-aa19a3afb0b94e8b5fe055eeb38b1fb2ee1a67b0.tar.xz cuberite-aa19a3afb0b94e8b5fe055eeb38b1fb2ee1a67b0.tar.zst cuberite-aa19a3afb0b94e8b5fe055eeb38b1fb2ee1a67b0.zip |
Diffstat (limited to 'src/FastRandom.h')
-rw-r--r-- | src/FastRandom.h | 36 |
1 files changed, 28 insertions, 8 deletions
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 <random> @@ -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<float> 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 |