Change batch/parallel Ranged Ingredient rolls from uniform random to gaussian random#4212
Change batch/parallel Ranged Ingredient rolls from uniform random to gaussian random#4212DilithiumThoride wants to merge 2 commits into
Conversation
|
You could just call it a In our case, we are essentially rolling The mean (Taken from Wikipedia, but this can be confirmed with the formulas for expected value and variance) Then, when rolling If we were to continue doing these rolls of If you want to learn more (and with visuals), 3b1b has a great video on the topic. Simply put, you just need a sample from a normal distribution that has the mean and variance that we want. This is fairly easy because the normal distribution is defined very conveniently. You can just take a random sample from the standard normal distribution (via a call to float mean = parallel * (min + max) / 2f;
int s = max - min + 1;
float sd = Math.sqrt(parallel * (s * s - 1) / 12f);
return random.nextGaussian() * sd + mean;Also I just looked and Mojang already has a ValueProvider that does this - |
|
That makes this all so much easier to both understand and implement. Thank you. |
|
I thought about it again and there is a small inconsistency in the math here. Our Glad to have helped you learn though :^) |
What
For normal ranged ingredients using UniformInt as their provider
When modified by a RecipeModifier to add batch/parallel counts, also replace the Uniform provider with a Gaussian provider, so that the roll is somewhat closer to "average" for a large number of rolls.
Implementation Details
The implementation here is still somewhat weird. Tech suggested using the Central Limit Theorem to modify the Gaussian standard deviation, but the Gaussian Random sources I have access to do not accept params to modify with. So this is getting held as a draft until I either have an answer to that problem, or we decide it doesn't matter.