TombEngine/TR5Main/Specific/prng.cpp

19 lines
356 B
C++
Raw Normal View History

2020-12-21 13:16:29 -03:00
#include "framework.h"
2021-09-08 18:31:35 +03:00
#include "Specific\prng.h"
2020-12-21 13:16:29 -03:00
#include <random>
2021-08-30 18:03:21 +03:00
namespace TEN::Math::Random
2020-12-21 13:16:29 -03:00
{
static std::mt19937 Engine;
2021-09-17 16:07:53 +03:00
int32_t GenerateInt(int32_t low, int32_t high)
2020-12-21 13:16:29 -03:00
{
return Engine() / (Engine.max() / (high - low + 1) + 1) + low;
}
2021-09-17 16:07:53 +03:00
float GenerateFloat(float low, float high)
2020-12-21 13:16:29 -03:00
{
return (high - low) * Engine() / Engine.max() + low;
}
}