diff options
author | André Nusser <andre.nusser@googlemail.com> | 2017-01-08 18:39:19 +0100 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2017-01-08 19:12:59 +0100 |
commit | b9ae5c7b6863eab945438972c6b7c905a1924297 (patch) | |
tree | e2e817350963586cddfb578f52d97fe3d9f007f8 /src/random.h | |
parent | 8dc3c0e2db6ce4f571d5b763c396bdab49f94889 (diff) |
Replace used <random> methods by own.
This makes our random numbers cross-platform.
Diffstat (limited to 'src/random.h')
-rw-r--r-- | src/random.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/random.h b/src/random.h index a18f5b6..7f53c05 100644 --- a/src/random.h +++ b/src/random.h @@ -56,12 +56,16 @@ private: // minstd_rand0, so make sure we use that all platforms regardless of which // stdlib we link with. std::minstd_rand0 generator; + + float generateFloat(); + + // variables for normalDistribution + bool has_saved_value = false; + float saved_value; }; template <typename T> T& Random::choose(std::vector<T>& vec) { - std::uniform_int_distribution<size_t> distribution(0, vec.size()-1); - size_t rand_index = distribution(generator); - return vec[rand_index]; + return vec[intInRange(0, vec.size() - 1)]; } |