Berry: Difference between revisions

904 bytes added ,  24 April 2021
→‎Formula: Correcting the probability of a maximum yield, using LaTeX to explain mathematical steps instead of a text description. Still not hugely satisfied with this section though, as it fails to really show that other values of rand don't work.
(→‎Formula: Correcting the probability of a maximum yield, using LaTeX to explain mathematical steps instead of a text description. Still not hugely satisfied with this section though, as it fails to really show that other values of rand don't work.)
Line 244: Line 244:


=====Formula=====
=====Formula=====
If a Berry plant is not watered at all during its growth, it will always bear its minimum number of fruit. Otherwise, the formula on the right is used to decide how many fruits a Berry tree will bear. The variables evaluate as follows:
If a Berry plant is not watered at all during its growth, it will always bear its minimum number of Berries. Otherwise, the number of Berries produced is calculated using the following formula:


<math>\Bigl \lfloor \dfrac{(max-min) \times (water - 1) + rand}{4}\Bigr \rfloor + min</math>
<math>Yield = \left\lfloor \dfrac{Yield_{range} \times (water - 1) + rand}{4} \right\rfloor + Yield_{min}</math>


*''max'' and ''min'' are the maximum and minimum number of Berries that can appear on the plant
*''Yield<sub>max</sub>'' and ''Yield<sub>min</sub>'' are the maximum and minimum number of Berries that can appear on the plant, respectively
*''rand'' is an integer randomly chosen between 0 and <code>''max'' - ''min''</code>, inclusive
*''Yield<sub>range</sub>'' is difference between ''Yield<sub>max</sub>'' and ''Yield<sub>min</sub>'', i.e. it is equal to <math>(Yield_{max}-Yield_{min})</math>
*''rand'' is an integer randomly chosen between 0 and <math>Yield_{range}</math>, inclusive
*''water'' is the number of growth stages during which the plant was watered
*''water'' is the number of growth stages during which the plant was watered
The difference between a Berry's maximum and minimum yield can range from 1 to 4, and there are 4 stages a Berry can be watered in. If the plant is fully watered (''water'' equals 4), then if ''rand'' equals <code>''max'' - ''min''</code>, the numerator is equal to <code>(''max'' - ''min'') × ''water''</code> and the denominator evenly divides ''water'', so that the formula evaluates to <code>''max'' - ''min'' + ''min''</code>, or ''max''. In short, there is a 1 in <code>''max'' - ''min'' + min</code> chance that a Berry plant will provide its maximum yield if it is fully watered.
 
Depending on the Berry, the difference between a Berry's maximum and minimum yield can be anywhere from 1 to 4. There are a total of 4 stages a Berry can be watered in, so the maximum possible value of ''water'' is 4.
 
=====
For a fully watered plant (i.e. ''water'' equals 4), the yield will only be the maximum yield if ''rand'' equals <math>Yield_{range}</math> (its maximum value). If ''rand'' is equal to ''Yield<sub>range</sub>'', then the formula can be evaluated as follows:
 
<math>
\begin{align}
Yield &= \left\lfloor \dfrac{Yield_{range} \times (4 - 1) + Yield_{range}}{4} \right\rfloor + Yield_{min} \\
&= \left\lfloor \dfrac{Yield_{range} \times 3 + Yield_{range}}{4} \right\rfloor + Yield_{min} \\
&= \left\lfloor \dfrac{Yield_{range} \times 4}{4} \right\rfloor + Yield_{min} \\
&= \left\lfloor Yield_{range} \right\rfloor + Yield_{min} \\
&= Yield_{range} + Yield_{min} \\
&= Yield_{max}
\end{align}
</math>
 
If ''rand'' were to be any smaller, the numerator would be less than <math>4 \cdot Yield_{range}</math>, so the integer division would evaluate to a value less than ''Yield<sub>max</sub>''. Consequently, since ''rand'' has <math>Yield_{range} + 1</math> possible values, there is a <math>\tfrac{1}{Yield_{range} + 1}</math> chance of a fully-watered Berry plant having its maximum yield.


=====Stages=====
=====Stages=====