From 669717268201197412c69df36e65883b0af6fac8 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Mon, 5 Nov 2018 10:06:37 -0800 Subject: Tests work now, + other cleanup --- Source/Random.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Random.cpp') diff --git a/Source/Random.cpp b/Source/Random.cpp index c921e58..d8f5eb2 100644 --- a/Source/Random.cpp +++ b/Source/Random.cpp @@ -7,8 +7,8 @@ void Random::SetSeed(int seed) { s_seed = seed; } +// Returns a random integer in [min, max] int Random::RandInt(int min, int max) { s_seed = (214013 * s_seed + 2531011) % 2147483648; - if (min == max) return min; - return (s_seed % (max - (min - 1))) + min; + return (s_seed % (max - min + 1)) + min; } -- cgit 1.4.1