Testing out RandN for better quality random. Also took out seeds until I can find a way to implement it that doesn't completely break gambling

This commit is contained in:
barelyprofessional
2025-10-05 01:40:05 -05:00
parent 115506ba42
commit cb7337375d
2 changed files with 6 additions and 1 deletions

View File

@@ -23,6 +23,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="NLog" Version="6.0.4" /> <PackageReference Include="NLog" Version="6.0.4" />
<PackageReference Include="Raffinert.FuzzySharp" Version="3.0.6" /> <PackageReference Include="Raffinert.FuzzySharp" Version="3.0.6" />
<PackageReference Include="RandN" Version="0.5.0" />
<PackageReference Include="System.Runtime.Caching" Version="9.0.9" /> <PackageReference Include="System.Runtime.Caching" Version="9.0.9" />
<PackageReference Include="System.Text.Json" Version="9.0.9" /> <PackageReference Include="System.Text.Json" Version="9.0.9" />
<PackageReference Include="Websocket.Client" Version="5.3.0" /> <PackageReference Include="Websocket.Client" Version="5.3.0" />

View File

@@ -5,6 +5,9 @@ using KfChatDotNetBot.Settings;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json; using Newtonsoft.Json;
using NLog; using NLog;
using RandN;
using RandN.Compat;
using RandN.Rngs;
namespace KfChatDotNetBot.Services; namespace KfChatDotNetBot.Services;
@@ -423,7 +426,8 @@ public static class Money
public static int GetRandomNumber(GamblerDbModel gambler, int min, int max, int iterations = 10, public static int GetRandomNumber(GamblerDbModel gambler, int min, int max, int iterations = 10,
bool incrementMaxParam = true) bool incrementMaxParam = true)
{ {
var random = new Random(gambler.RandomSeed.GetHashCode()); var rng = StandardRng.Create();
var random = RandomShim.Create(rng);
var result = 0; var result = 0;
var i = 0; var i = 0;
if (incrementMaxParam) max++; if (incrementMaxParam) max++;