[1.7.10, 1.10.2, 1.11,2] Actual chance for Valiant bees is far less than intended
rmunn opened this issue ยท 2 comments
As with ForestryMC/ForestryMC#1752, in Extra Bees the actual drop rate for Valiant bees is far less than intended due to the order in which drops from worldgen hives are calculated. When you look at the following code, what does it look like the rate of Valiant bees is?
IAlleleBeeSpecies valiantSpecies = Utils.getSpecies(BeeDefinition.VALIANT);
EnumHiveType.Water.drops.add(new HiveDrop(ExtraBeesSpecies.WATER, 80));
EnumHiveType.Water.drops.add(new HiveDrop(valiantSpecies, 3));
EnumHiveType.Rock.drops.add(new HiveDrop(ExtraBeesSpecies.ROCK, 80));
EnumHiveType.Rock.drops.add(new HiveDrop(valiantSpecies, 3));
EnumHiveType.Nether.drops.add(new HiveDrop(ExtraBeesSpecies.BASALT, 80));
EnumHiveType.Nether.drops.add(new HiveDrop(valiantSpecies, 3));
EnumHiveType.Marble.drops.add(new HiveDrop(ExtraBeesSpecies.MARBLE, 80));
EnumHiveType.Marble.drops.add(new HiveDrop(valiantSpecies, 3));
It looks like there's an 80% chance for the "normal" hive drop, and a 3% chance for Valiant bees, right? In fact, the actual drop rate for normal bees is indeed 80%, but the drop rate for Valiant bees is actually 0.6%. The reason why is because of how hive drops are calculated: we go through the possible drops one at a time, rolling for each one โ and when one hive drop succeeds, we stop checking.
Therefore, the only way for a Valiant princess (or drone) to drop is for the "regular" hive bee to fail to drop, a 20% chance, and then for the Valiant bee to succeed at the 3% roll. So the actual chance for a Valiant bee (either princess or drone) to drop is 0.2 * 0.03 = 0.006 = 0.6%.
There's a simple way to solve this: simply flip the order of the hive drop registrations around, so that Valiant bees are registered first, then the "regular" hive bees. See ForestryMC/MagicBees#23 for all the mathy details, but basically, it keeps the total chance of drops from a hive exactly the same at 80.6% total, but instead of an 80% chance of getting a regular bee and a 0.6% chance of getting a Valiant bee, checking for the Valiant bee first ends up giving you a 3% chance of getting a Valiant bee, and a 77.6% chance of getting a regular bee.
So to make Valiant bees drop at the rate they were originally intended to drop, 3% (or 5% from Magic Bees hives), the fix is simply to rewrite the hive-drops code as:
IAlleleBeeSpecies valiantSpecies = Utils.getSpecies(BeeDefinition.VALIANT);
EnumHiveType.Water.drops.add(new HiveDrop(valiantSpecies, 3));
EnumHiveType.Water.drops.add(new HiveDrop(ExtraBeesSpecies.WATER, 80));
EnumHiveType.Rock.drops.add(new HiveDrop(valiantSpecies, 3));
EnumHiveType.Rock.drops.add(new HiveDrop(ExtraBeesSpecies.ROCK, 80));
EnumHiveType.Nether.drops.add(new HiveDrop(valiantSpecies, 3));
EnumHiveType.Nether.drops.add(new HiveDrop(ExtraBeesSpecies.BASALT, 80));
EnumHiveType.Marble.drops.add(new HiveDrop(valiantSpecies, 3));
EnumHiveType.Marble.drops.add(new HiveDrop(ExtraBeesSpecies.MARBLE, 80));
To change the order of the registration of the drops would change nothing, because we are shuffle the list.
Ah, I missed that. Yes, if the list is shuffled then both the hive bee and the Valiant bee have a chance of being first. The Valiant bee still isn't at a real 3% drop rate โ it's got a 50% chance of having a 3% rate, and a 50% chance of having a 0.6% rate, which adds up to a total of 0.015 + 0.003 = 0.018 = 1.8% real chance to drop โ but that's still reasonable, and not too far off from the intended 3% drop rate. So nothing probably needs to change in the Extra Bees code. I'll go verify the other two issues I just created, and see if they're also mooted.