*Welcome to the first installment of Video Game Probability! You can read the introduction and motivation for this series here along with a list of all posts. This post contains mild spoilers for probability distributions in Stardew Valley. Without further ado, I’m going to jump in!*

Stardew Valley is a farming/lifestyle RPG where you grow crops, fish, find love, fight monsters, go on quests, and so much more. I have so much to say about this game and I’m trying so hard to hold in my enthusiasm – I hope you appreciate the sacrifices I make in the name of succinct writing. (But no really I love this game, it’s on Steam, it’s on Switch, it’s even on iOS and Android, so you have no excuse not to play it, please give it a try, it has something for everyone.)

One of your major tasks in Stardew Valley is to fix the Community Center. If you have no soul, you can go corporate and pay a ton of money, but most people go for the Bundle route because they’re not dead inside. A bundle is a set of items (crops, foraged goods, etc) that you donate to the spirits of the forest in exchange for rewards. Once you complete every bundle, you fix the Community Center!

Today, we’re going to talk about the Quality Crops bundle: you must gather 5 golden parsnips, melons, pumpkins, and corn to complete the bundle. The pesky thing about these crops is that parsnips are only grown in spring, melons are only grown in summer, pumpkins are only grown in fall, and corn can be grown in summer or fall.* So if you reach the end of spring or summer and didn’t manage to collect the 5 crops for that season, you have to wait a whole year for another chance!*

When you harvest a crop, it has a chance of being regular, silver, or gold quality. The game calculates your chances based on your farming level and what fertilizer, if any, was used. (Note: While “luck” is a mechanic in the game that I’d love to explore further, I don’t think your daily luck affects your harvests – correct me if I’m wrong!)

Here’s our big question for this post: How many crops should we plant with what fertilizer in order to guarantee a certain probability of getting at least 5 golden crops?

If you want to skip over the math, you should use the table of contents below to jump down to the conclusion!

# What are our levers?

We have quite a few factors we can tweak to optimize our probability. For example, if you’re early-game and don’t have a high farming level, time, energy, or sprinklers, you might want to buy fertilizer so you don’t have to care for too many crops everyday. Here are the relevant factors:

## Farming level

You increase your farming level by harvesting more crops. Farming level only increases overnight, so you can’t pick a hundred unrelated crops one day and then immediately go pick your desired parsnips. You can eat certain foods to increase your level temporarily.

## Fertilizer

You can use no fertilizer, basic fertilizer, or quality fertilizer. It would be cool if we could figure out how cheap we can be with the fertilizer based on other factors! I’m actually not sure if it’s always best to buy quality fertilizer. We’ll find out!

## Total crops planted

We can always grow a huge amount of crops all at once so that we have more chances at harvesting golden ones.

## Number of crop planting sessions

It doesn’t take a whole season for these crops to grow. We could grow one set of crops, see how many golden crops we got, and then plant more. You have to be careful with your schedule, though, because there’s only 28 days in the season. Don’t plant more crops if they won’t be ready by the end of the season! For the sake of brevity, we’re going to assume you are trying to get all 5 golden crops in one shot. Of course, your probability would increase if you try again.

# What are the chances of getting a single golden crop (`P(gold)`

)?

The Stardew Valley Wiki’s Farming page shows tables breaking down the probability distribution of quality of a single crop by your farming level and fertilizer choice. For example, here’s the quality fertilizer table:

I’m not sure how, but they looked into the game’s probability formula in order to get these numbers:

P(\text{gold}) = 0.01 + 0.2 * \left(\frac{L}{10} + \frac{F * (L + 2)}{12}\right)

(They mention on the wiki that `F`

(fertilizer) is equal to 0 for no fertilizer, 1 for basic fertilizer, and 2 for quality fertilizer.)

In short, we don’t have to do much work for the single crop question because the wiki already went through it! We’ll use the tables in the wiki going forward rather than redoing the math.

# What are the chances of getting *exactly* 5 golden crops if I planted `N`

crops with `P(gold)`

?

I have to admit that when I’m looking at a probability problem, I find it easier to work with concrete numbers, check if my solution makes intuitive sense, and then generalize it so that it works for all values.

What if I planted 5 crops and I want every single crop to be gold? The chances of all 5 crops being golden is `P(gold)*P(gold)*P(gold)*P(gold)*P(gold)`

, or P(\text{gold})^5.

When `P(gold) = 0.13,`

0.13^5 = 0.0037\%. In other words, it’s nearly impossible. But what if I’m actually a level 10 farmer?! Then P(\text{gold}) = 61\% (from the table above) and we see that 0.61^5 = 8.4\%. That’s a huge change! But still, 8.4% is not enough. I’m not betting my Community Center success on 8.4%!

Note that this formula does not generalize. The problem is that this formula assumes that we need every single “try” (each individual crop) to be golden. But if `N`

gets bigger, then we can’t just replace the 5 in the previous calculation with `N`

because then we’d be calculating the probability that every single try was successful. We need *exactly** 5* to succeed, and `N`

is bigger than 5.

To make this more concrete, consider if `N`

is 10 and I use the same formula from before: 0.61^{10} = 0.71\%. Intuitively, this doesn’t sound right. I increased `N`

, but the probability is significantly smaller. Again, that’s because this is the probability that I planted 10 crops and all 10 of them were golden.

We need to account for the “5 out of `N`

” somewhere. This was really hard for me to wrap my head around, because I didn’t know how to express “it doesn’t matter which 5, just that there are 5 of them.” This is really one of those times where it helps to break it down into very small numbers and look at each case.

What if I planted 2 crops and wanted exactly 1 of them to be golden? That’s easier! Because there are only four possible outcomes, I could just enumerate them: two golds, one gold and not gold, one not gold and gold, and no golds. Then I could sum up the probability of the cases that I want: “one gold and not gold, one not gold and gold”:

P(\text{gold})*P(\text{not gold}) + P(\text{not gold})*P(\text{gold})

0.61 * (1 - 0.61) + (1 - 0.61) * 0.61 = 47.6\%

But how do we generalize this beyond just 2 crops? This is where I have to handwave just a little bit and introduce the “binomial coefficient” – it’s not scary, I promise!

(Confession: I always call it “the choose” and didn’t remember that it was called the binomial coefficient until I looked it up for this blog post. Highkey would write a Cardcaptor Sakura spinoff about math where her first card is “The Choose” but I realize that the target demographic here is nonexistent.)

Anyway, let me put it this way: How many ways are there to choose 1 crop to be golden when there are 2 total crops? There are 2 ways! You could choose the first one, or you could choose the second one.

But how many ways are there to choose 2 crops out of 3? You could choose the first and second, the second and third, or the first and third, so there are 3 ways. It’s a little hard to enumerate all the options, but it’s not impossible.

But what if I ask you how many ways there are to choose 5 crops out of 10? You could choose the first five, or the last 5, or the 1st, 4th, 5th, 8th, and 9th… 🤯 no no no we can’t do this.

Binomial coefficient to the rescue! The binomial coefficient is a formula for calculating these types of numbers so that you don’t have to. You can represent this question verbally as “10 choose 5”. You can even Google it:

If you’re writing a mathematical formula, you would use this notation:

\binom{10}{5}

(For \LaTeX fans, that’s `\binom{10}{5}`

in math mode!)

So it turns out that we don’t have to do the work of calculating “how many ways are there for this to happen?” – when we can phrase a question as “how many ways are there for me to have `N`

total tries and to succeed exactly `k`

times”, we should use “N choose k” or \binom{N}{k}.

Let’s come back to our work for “1 golden crop out of 2 total crops”. We can use Google to see that \binom{2}{1} = 2. In fact, for any \binom{N}{1}, the answer is always `N`

because there are exactly `N`

ways to choose one of the items! This actually matches the work that we did earlier:

P(\text{gold})*P(\text{not gold}) + P(\text{not gold})*P(\text{gold})

simplifies to

2\left(P(\text{gold}) * P(\text{not gold})\right)

The \binom{2}{1} = 2 was hiding in plain sight!

The last piece of this puzzle is how to account for the “probability of all the other attempts”. I can’t slam in a \binom{N}{k} into that previous formula because it’s only accounting for two total attempts. The first P(\text{gold}) is for the first crop. The second P(\text{not gold}) is for the second crop. If we have more crops, we have to include them.

For example, if we wanted to calculate the “2 golden crops out of 3 total crops” case, we could safely write:

\binom{3}{2}P(\text{gold})*P(\text{gold})*P(\text{not gold})

(Intuition check: When P(\text{gold}) = 0.61, this comes out to 43.5%. That feels right to me.)

In other words, we have to multiply out the number of successful tries we want versus the number of unsuccessful tries.

To generalize this and put it all together, when we want the probability of exactly `k`

golden crops out of `N`

, here’s our formula:

\boxed{\binom{N}{k}P(\text{gold})^k*P(\text{not gold})^{\left(N - k\right)}}

To finally answer the original question of this section: What are my chances of getting *exactly* 5 golden crops if I plant 10 crops (with level 10 farming and golden fertilizer)?

\binom{N}{k}P(\text{gold})^k*P(\text{not gold})^{\left(N - k\right)}

\binom{10}{5}0.61^5*0.39^5 = 19.2\%

Wow, that was a lot of work, but we got there! We proved it’s unlikely but possible to get *exactly* 5 golden crops out of 10! For the heck of it, I plugged in 0.13 (for a level 1 farmer) and got 0.46%. So level 1 farmers are pretty screwed!

Waitaminute! What about that “exactly” that I keep italicizing? I’m okay with getting more than 5 golden crops, right? To the next section!

# What are the chances of getting *at least* 5 golden crops if I planted `N`

crops with `P(gold)`

?

After all of that work we did in the previous section, it turns out this section is much shorter. We just have to do a summation:

\boxed{\sum_{x=k}^{N} \binom{N}{x}P(\text{gold})^x*P(\text{not gold})^{\left(N - x\right)}}

I mean, in concrete words, we sum the chances of getting exactly 5 crops out of 10, exactly 6 crops out of 10, and so on. If you want to dig deeper, it’s valid for us to just add the values together because of the inclusion-exclusion principle or something like that. (I’m handwaving because I’m already 2000 words deep and trying to get out of here.)

Plugging the numbers in:

\sum_{x=5}^{10} \binom{10}{x} 0.61^x* 0.39^{\left(10 - x\right)} = 85\%

Note: I had to use my good friend Wolfram Alpha here, and I had to do a lot of syntax wrangling to get it to work because it didn’t like the choose combined with the summation. Here’s the link to my query.

Anyway, 85% is pretty good! And for my sad level 1 farmer with `P(gold) = 0.13`

, we get a measly 0.52%. But this is only with 10 crops!

# Just tell me how many crops to plant! 🤬

At this point, you have to decide what your risk tolerance is (e.g., is 90% chance of success acceptable?) and fiddle with the numbers until you get a probability that you’re okay with. You can use this Wolfram Alpha formula and change `p`

and `n`

:

`p = 0.61; n = 10; sum (p^x * ((1-p)^(n-x)) * (n choose x)), x=5 to n`

In my case, I’m a lazy farmer and I always forget to use fertilizer. So I went back to the Stardew Valley Wiki and looked up the probability for a level 10 farmer with no fertilizer: 21%. I saw that when `n = 48`

, I have a 98% chance of getting at least 5 golden crops. And those odds are good enough for me!

I’ll leave it as an exercise to the reader to figure out the probability formula for multiple attempts. (Read: I can’t emotionally handle typesetting anymore LaTeX so I’m bailing.)

Huge thanks to Keith Schwarz for talking to me about this problem and patiently responding to all my math questions at all hours of the day.

# Edit (May 12): Additional links!

- I’m sure my probability professor mentioned Bernoulli trials at some point in our class, but I somehow managed to forget the name entirely. I knew that the formula I reached was a commonly accepted formula, but couldn’t remember the terminology, and so I couldn’t find the relevant Wikipedia article. I’d recommend taking a look if you want to read more about the history of this formula and other applications.
- I made a Stardew Valley calculator so you can plug in the values from this post and see how they change!