Use RandN properly and get rid of the iterations thingy for next double

This commit is contained in:
barelyprofessional
2026-02-19 20:55:55 -06:00
parent f1ab9cfcdd
commit 6967a81d73
2 changed files with 6 additions and 14 deletions

View File

@@ -8,6 +8,7 @@ using Microsoft.EntityFrameworkCore;
using NLog;
using RandN;
using RandN.Compat;
using RandN.Distributions;
namespace KfChatDotNetBot.Services;
@@ -448,22 +449,13 @@ public static class Money
/// Get random number double [0, 1]
/// </summary>
/// <param name="gambler">Gambler entity to reference their random seed</param>
/// <param name="iterations">Number of random number generator iterations to run before returning a result</param>
/// <returns>A random number based on the given parameters</returns>
/// <exception cref="ArgumentException"></exception>
public static double GetRandomDouble(GamblerDbModel gambler, int iterations = 10)
public static double GetRandomDouble(GamblerDbModel gambler)
{
var rng = StandardRng.Create();
var random = RandomShim.Create(rng);
var result = 0.0;
var i = 0;
if (iterations <= 0) throw new ArgumentException("Iterations cannot be 0 or lower");
while (i < iterations)
{
i++;
result = random.NextDouble();
}
return result;
var dist = Uniform.New(0.0, 1.0);
return dist.Sample(rng);
}
/// <summary>