mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
Use RandN properly and get rid of the iterations thingy for next double
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user