1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-05 15:55:45 +00:00
OpenMW/components/misc/rng.hpp

40 lines
1.0 KiB
C++
Raw Normal View History

2015-04-22 15:58:55 +00:00
#ifndef OPENMW_COMPONENTS_MISC_RNG_H
#define OPENMW_COMPONENTS_MISC_RNG_H
#include <cassert>
2018-04-08 20:10:14 +00:00
#include <random>
/*
Provides central implementation of the RNG logic
*/
namespace Misc::Rng
{
using Generator = std::mt19937;
Generator& getGenerator();
/// returns default seed for RNG
unsigned int generateDefaultSeed();
2018-04-08 20:10:14 +00:00
/// seed the RNG
void init(unsigned int seed = generateDefaultSeed());
/// return value in range [0.0f, 1.0f) <- note open upper range.
float rollProbability(Generator& prng = getGenerator());
/// return value in range [0.0f, 1.0f] <- note closed upper range.
float rollClosedProbability(Generator& prng = getGenerator());
/// return value in range [0, max) <- note open upper range.
int rollDice(int max, Generator& prng = getGenerator());
/// return value in range [0, 99]
inline int roll0to99(Generator& prng = getGenerator()) { return rollDice(100, prng); }
float deviate(float mean, float deviation, Generator& prng = getGenerator());
}
#endif