mirror of
https://github.com/sp-tarkov/loot-dump-processor.git
synced 2025-02-13 07:10:45 -05:00
Replaced NumSharp with custom math functions for mean and standard deviation calculations
This commit is contained in:
parent
36917aa556
commit
f31fdaa27d
@ -1,36 +1,35 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ServerGarbageCollection>true</ServerGarbageCollection>
|
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||||
<GarbageCollectionAdaptationMode>1</GarbageCollectionAdaptationMode>
|
<GarbageCollectionAdaptationMode>1</GarbageCollectionAdaptationMode>
|
||||||
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
|
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="7z.Libs" Version="21.7.0" />
|
<PackageReference Include="7z.Libs" Version="21.7.0"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.0"/>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.2"/>
|
||||||
<PackageReference Include="NumSharp" Version="0.30.0" />
|
<PackageReference Include="SevenZipSharp.Interop" Version="19.1.0"/>
|
||||||
<PackageReference Include="SevenZipSharp.Interop" Version="19.1.0" />
|
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0"/>
|
||||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
|
<PackageReference Include="YamlDotNet" Version="13.0.0"/>
|
||||||
<PackageReference Include="YamlDotNet" Version="13.0.0" />
|
</ItemGroup>
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="Config\forced_loose.yaml">
|
<None Update="Config\forced_loose.yaml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Config\forced_static.yaml">
|
<None Update="Config\forced_static.yaml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Config\config.json">
|
<None Update="Config\config.json">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -6,7 +6,6 @@ using LootDumpProcessor.Storage;
|
|||||||
using LootDumpProcessor.Storage.Collections;
|
using LootDumpProcessor.Storage.Collections;
|
||||||
using LootDumpProcessor.Utils;
|
using LootDumpProcessor.Utils;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NumSharp;
|
|
||||||
|
|
||||||
namespace LootDumpProcessor.Process.Processor.v2.LooseLootProcessor
|
namespace LootDumpProcessor.Process.Processor.v2.LooseLootProcessor
|
||||||
{
|
{
|
||||||
@ -61,7 +60,7 @@ namespace LootDumpProcessor.Process.Processor.v2.LooseLootProcessor
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
var config = LootDumpProcessorContext.GetConfig();
|
var config = LootDumpProcessorContext.GetConfig();
|
||||||
var spawnPointTolerance = config.ProcessorConfig.SpawnPointToleranceForForced / 100;
|
var spawnPointTolerance = config.ProcessorConfig.SpawnPointToleranceForForced / 100.0;
|
||||||
var looseLootDistribution = new LooseLootRoot();
|
var looseLootDistribution = new LooseLootRoot();
|
||||||
|
|
||||||
var probabilities = new Dictionary<string, double>();
|
var probabilities = new Dictionary<string, double>();
|
||||||
@ -73,9 +72,9 @@ namespace LootDumpProcessor.Process.Processor.v2.LooseLootProcessor
|
|||||||
probabilities[itemId] = (double)count / mapCount;
|
probabilities[itemId] = (double)count / mapCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
var spawnPointCount = looseLootCountsItem.MapSpawnpointCount.Select(Convert.ToDouble);
|
var spawnPointCount = looseLootCountsItem.MapSpawnpointCount.Select(Convert.ToDouble).ToList();
|
||||||
var initialMean = np.mean(np.array(spawnPointCount)).ToArray<double>().First();
|
var initialMean = CalculateMean(spawnPointCount);
|
||||||
var tolerancePercentage = config.ProcessorConfig.LooseLootCountTolerancePercentage / 100;
|
var tolerancePercentage = config.ProcessorConfig.LooseLootCountTolerancePercentage / 100.0;
|
||||||
var highThreshold = initialMean * (1 + tolerancePercentage);
|
var highThreshold = initialMean * (1 + tolerancePercentage);
|
||||||
|
|
||||||
looseLootCountsItem.MapSpawnpointCount = looseLootCountsItem.MapSpawnpointCount
|
looseLootCountsItem.MapSpawnpointCount = looseLootCountsItem.MapSpawnpointCount
|
||||||
@ -84,8 +83,8 @@ namespace LootDumpProcessor.Process.Processor.v2.LooseLootProcessor
|
|||||||
|
|
||||||
looseLootDistribution.SpawnPointCount = new SpawnPointCount
|
looseLootDistribution.SpawnPointCount = new SpawnPointCount
|
||||||
{
|
{
|
||||||
Mean = np.mean(np.array(looseLootCountsItem.MapSpawnpointCount)),
|
Mean = CalculateMean(looseLootCountsItem.MapSpawnpointCount.Select(Convert.ToDouble).ToList()),
|
||||||
Std = np.std(np.array(looseLootCountsItem.MapSpawnpointCount))
|
Std = CalculateStandardDeviation(looseLootCountsItem.MapSpawnpointCount.Select(Convert.ToDouble).ToList())
|
||||||
};
|
};
|
||||||
looseLootDistribution.SpawnPointsForced = new List<SpawnPointsForced>();
|
looseLootDistribution.SpawnPointsForced = new List<SpawnPointsForced>();
|
||||||
looseLootDistribution.SpawnPoints = new List<SpawnPoint>();
|
looseLootDistribution.SpawnPoints = new List<SpawnPoint>();
|
||||||
@ -227,5 +226,21 @@ namespace LootDumpProcessor.Process.Processor.v2.LooseLootProcessor
|
|||||||
|
|
||||||
return looseLootDistribution;
|
return looseLootDistribution;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double CalculateMean(IReadOnlyList<double> numbers)
|
||||||
|
{
|
||||||
|
if (!numbers.Any()) return 0;
|
||||||
|
|
||||||
|
return numbers.Average();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double CalculateStandardDeviation(IReadOnlyList<double> numbers)
|
||||||
|
{
|
||||||
|
if (numbers.Count == 0) return 0;
|
||||||
|
|
||||||
|
var mean = CalculateMean(numbers);
|
||||||
|
var variance = numbers.Sum(num => Math.Pow(num - mean, 2)) / numbers.Count;
|
||||||
|
return Math.Sqrt(variance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user