/// <inheritdoc /> public void AssignIVsAndEVsToTeam(PokeList list, int level) { foreach (var poke in list.Pokemon) { // EVs between 0-65535 poke.AttackEV = (ushort)_probabilityUtility.GaussianRandomSkewed(0, 65535, level / 100D); poke.DefenseEV = (ushort)_probabilityUtility.GaussianRandomSkewed(0, 65535, level / 100D); poke.HitPointsEV = (ushort)_probabilityUtility.GaussianRandomSkewed(0, 65535, level / 100D); poke.SpecialEV = (ushort)_probabilityUtility.GaussianRandomSkewed(0, 65535, level / 100D); poke.SpeedEV = (ushort)_probabilityUtility.GaussianRandomSkewed(0, 65535, level / 100D); // IVs between 0-15 poke.AttackIV = (byte)_probabilityUtility.GaussianRandom(0, 15); poke.DefenseIV = (byte)_probabilityUtility.GaussianRandom(0, 15); poke.SpecialIV = (byte)_probabilityUtility.GaussianRandom(0, 15); poke.SpeedIV = (byte)_probabilityUtility.GaussianRandom(0, 15); } }
public void GaussianRandomWithConfigTest(int low, int high, double meanConfig, double stdDeviationConfig) { config.Mean = meanConfig; config.StandardDeviation = stdDeviationConfig; probabilityUtility = new ProbabilityUtility(random, config); var result = Enumerable.Range(0, iterations).Select(i => probabilityUtility.GaussianRandom(low, high)); var resultMean = result.Average(); var resultStdDeviation = Math.Sqrt(result.Select(i => Math.Pow(i - resultMean, 2D)).Average()); var mean = low + (high - low) * meanConfig; var stdev = (high - low) * stdDeviationConfig; // Assert Assert.True(Math.Abs(resultMean - mean) / mean <= stdDeviation, $"Mean Expected: {mean}, Actual: {resultMean}"); Assert.True(Math.Abs(resultStdDeviation - stdev) / stdev <= stdDeviation, $"Standard Deviation Expected: {stdev}, Actual: {resultStdDeviation}"); }