about summary refs log tree commit diff stats
path: root/Source/Random.cpp
blob: 61fd30fa6a8c7ac98f868d8e2175acc1c5912f7c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <chrono>
#include "Random.h"

int Random::s_seed = static_cast<int>(time(nullptr)); // Seed from the time in milliseconds

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;
    return (s_seed % (max - min + 1)) + min;
}