diff options
| author | jbzdarkid <jbzdarkid@gmail.com> | 2018-10-30 20:00:32 -0700 |
|---|---|---|
| committer | jbzdarkid <jbzdarkid@gmail.com> | 2018-10-30 20:00:32 -0700 |
| commit | e66a408e38849107a3d35a317ff6f2b23dcaeead (patch) | |
| tree | 2e2abb9c80997c0565fddce4e7e271d901839b26 /Source/Random.h | |
| parent | 2ec4950107245df8f01860a3289b7731753933cd (diff) | |
| download | witness-tutorializer-e66a408e38849107a3d35a317ff6f2b23dcaeead.tar.gz witness-tutorializer-e66a408e38849107a3d35a317ff6f2b23dcaeead.tar.bz2 witness-tutorializer-e66a408e38849107a3d35a317ff6f2b23dcaeead.zip | |
RM static cast, lower warning level, add homebrew RNG
Diffstat (limited to 'Source/Random.h')
| -rw-r--r-- | Source/Random.h | 17 |
1 files changed, 17 insertions, 0 deletions
| diff --git a/Source/Random.h b/Source/Random.h new file mode 100644 index 0000000..e4700f3 --- /dev/null +++ b/Source/Random.h | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | static int s_seed; | ||
| 4 | |||
| 5 | class Random | ||
| 6 | { | ||
| 7 | public: | ||
| 8 | static void SetSeed(int seed) { | ||
| 9 | s_seed = seed; | ||
| 10 | } | ||
| 11 | |||
| 12 | static int RandInt(int min, int max) { | ||
| 13 | s_seed = (214013 * s_seed + 2531011) % 2147483648; | ||
| 14 | if (min == max) return min; | ||
| 15 | return (s_seed % (max - (min - 1))) + min; | ||
| 16 | } | ||
| 17 | }; | ||
