Moved rng-methods to their own class/header

This commit is contained in:
Leonetienne
2021-11-18 20:19:29 +01:00
parent 72fc9b3538
commit 1cc7699939
15 changed files with 233 additions and 161 deletions

41
Test/Random.h Normal file
View File

@@ -0,0 +1,41 @@
#pragma once
#include <random>
namespace Eule
{
/** Extensive random number generator
*/
class Random
{
public:
//! Will return a random double between `0` and `1`
static double Rand();
//! Will return a random unsigned integer.
static unsigned int RandomUint();
//! Will return a random integer
static unsigned int RandomInt();
//! Will return a random double within a range
//! These bounds are INCLUSIVE!
static double RandomRange(const double min, const double max);
//! Will return a random integer within a range. This is faster than `(int)RandomRange(x,y)`
//! These bounds are INCLUSIVE!
static int RandomIntRange(const int max, const int min);
//! Will 'roll' a dice, returning `true` \f$100 * chance\f$ percent of the time.
static bool RandomChance(const double chance);
private:
//! Will initialize the random number generator
static void InitRng();
static std::mt19937 rng;
static bool isRngInitialized;
// No instanciation! >:(
Random();
};
}