public void HooksFishWithNormalRarityDistribution() { var fisher = FisherData.First(); AppSettings.FishingUseNormalRarity = true; var rarities = FishData.Select(x => x.Rarity).Distinct().ToArray(); var sampleSize = 10000; var samples = new List <Fish>(); for (var i = 0; i < sampleSize; i++) { System.HookFish(fisher); samples.Add(fisher.Hooked); } var commonCount = samples.Count(x => x.Rarity.Equals(rarities[0])); var uncommonCount = samples.Count(x => x.Rarity.Equals(rarities[1])); var rareCount = samples.Count(x => x.Rarity.Equals(rarities[2])); Assert.IsTrue(commonCount >= sampleSize * 0.67 && commonCount <= sampleSize * 0.70); Assert.IsTrue(uncommonCount >= sampleSize * 0.25 && uncommonCount <= sampleSize * 0.28); Assert.IsTrue(rareCount > 0 && rareCount <= sampleSize * 0.05); }
public void HooksFishWithWeightedRarityDistribution() { var fisher = FisherData.First(); var rarities = FishData.Select(x => x.Rarity).Distinct().ToArray(); var sampleSize = 10000; var samples = new List <Fish>(); for (var i = 0; i < sampleSize; i++) { System.HookFish(fisher); samples.Add(fisher.Hooked); } var weightTotal = (float)rarities.Sum(x => x.Weight); var commonCount = samples.Count(x => x.Rarity.Equals(rarities[0])); var uncommonCount = samples.Count(x => x.Rarity.Equals(rarities[1])); var rareCount = samples.Count(x => x.Rarity.Equals(rarities[2])); var commonWeight = (float)rarities[0].Weight / weightTotal; var uncommonWeight = (float)rarities[1].Weight / weightTotal; var rareWeight = (float)rarities[2].Weight / weightTotal; Assert.IsTrue(commonCount >= sampleSize * (commonWeight / 1.1) && commonCount <= sampleSize * (commonWeight * 1.1)); Assert.IsTrue(uncommonCount >= sampleSize * (uncommonWeight / 1.1) && uncommonCount <= sampleSize * (uncommonWeight * 1.1)); Assert.IsTrue(rareCount >= sampleSize * (rareWeight / 1.1) && rareCount <= sampleSize * (rareWeight * 1.1)); }