/// <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);
            }
        }
Пример #2
0
        public void GaussianRandomSkewedWithConfigTest(int low, int high, double meanConfig, double stdDeviationConfig, int level)
        {
            config.Mean = meanConfig;
            config.StandardDeviation = stdDeviationConfig;
            probabilityUtility       = new ProbabilityUtility(random, config);

            var result             = Enumerable.Range(0, iterations).Select(i => probabilityUtility.GaussianRandomSkewed(low, high, level / 100D));
            var resultMean         = result.Average();
            var resultStdDeviation = Math.Sqrt(result.Select(i => Math.Pow(i - resultMean, 2D)).Average());

            var skew  = level / 100D * config.Skew * 2D - config.Skew;
            var mean  = Math.Min(high, Math.Max(low, low + (high - low) * config.Mean + skew));
            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}");
        }