1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-03 00:46:55 +02:00

Replaced most of usages of CRandomGenerator with vstd::RNG in library

This commit is contained in:
Ivan Savenko
2024-06-01 15:28:17 +00:00
parent 60a51e98de
commit 63bcf7d83c
125 changed files with 620 additions and 409 deletions

View File

@ -40,6 +40,11 @@ int CRandomGenerator::nextInt(int upper)
return nextInt(0, upper);
}
int64_t CRandomGenerator::nextInt64(int64_t upper)
{
return nextInt64(0, upper);
}
int CRandomGenerator::nextInt(int lower, int upper)
{
if (lower > upper)
@ -53,6 +58,12 @@ int CRandomGenerator::nextInt()
return TIntDist()(rand);
}
int CRandomGenerator::nextBinomialInt(int coinsCount, double coinChance)
{
std::binomial_distribution<> distribution(coinsCount, coinChance);
return distribution(rand);
}
int64_t CRandomGenerator::nextInt64(int64_t lower, int64_t upper)
{
if (lower > upper)
@ -74,20 +85,11 @@ double CRandomGenerator::nextDouble(double lower, double upper)
return TRealDist(lower, upper)(rand);
}
//double CRandomGenerator::nextDouble()
//{
// return TRealDist()(rand);
//}
CRandomGenerator & CRandomGenerator::getDefault()
{
static thread_local CRandomGenerator defaultRand;
return defaultRand;
}
TGenerator & CRandomGenerator::getStdGenerator()
{
return rand;
}
VCMI_LIB_NAMESPACE_END