diff options
author | jbzdarkid <jbzdarkid@gmail.com> | 2018-11-05 07:21:05 -0800 |
---|---|---|
committer | jbzdarkid <jbzdarkid@gmail.com> | 2018-11-05 07:21:05 -0800 |
commit | a2913485f2b072f0f3c531b9ef2e89ed066ec128 (patch) | |
tree | 9a7c28fe5c48a63c11e27950c975149991e8dba8 /Source/Random.cpp | |
parent | e48ce4469cee270687e04bc1a2b91d3c2bba0789 (diff) | |
download | witness-tutorializer-a2913485f2b072f0f3c531b9ef2e89ed066ec128.tar.gz witness-tutorializer-a2913485f2b072f0f3c531b9ef2e89ed066ec128.tar.bz2 witness-tutorializer-a2913485f2b072f0f3c531b9ef2e89ed066ec128.zip |
Fix RNG not changing
Diffstat (limited to 'Source/Random.cpp')
-rw-r--r-- | Source/Random.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Source/Random.cpp b/Source/Random.cpp new file mode 100644 index 0000000..cc3eb6c --- /dev/null +++ b/Source/Random.cpp | |||
@@ -0,0 +1,15 @@ | |||
1 | #include <chrono> | ||
2 | |||
3 | #include "Random.h" | ||
4 | |||
5 | int Random::s_seed = time(nullptr); // Seed from the time in milliseconds | ||
6 | |||
7 | void Random::SetSeed(int seed) { | ||
8 | s_seed = seed; | ||
9 | } | ||
10 | |||
11 | int Random::RandInt(int min, int max) { | ||
12 | s_seed = (214013 * s_seed + 2531011) % 2147483648; | ||
13 | if (min == max) return min; | ||
14 | return (s_seed % (max - (min - 1))) + min; | ||
15 | } | ||