Summertime, and the lemonade is easy

Raymond Chen

Back in my youth, my brother and I played many games of Lemonade Stand, a simple BASIC game that put you in charge of a virtual lemonade stand. You had to decide, based on the weather report and the cost of materials, how much lemonade to make, how many advertising signs to put up, and how much to charge. We had settled upon our idea of what an optimal configuration was, but I always wondered whether we had actually found it. (You too can play the game in an emulator and see how well you do.)

No fear, the game has been ported to Windows and Mac OS X. That web site also includes the original source code, so you can port it to JavaScript if you feel so motivated. As for me, I extracted the formulas and did my own calculations.

Here are the formulas. All money amounts are in cents.

Nominal demand is in two parts.

If price ≤ 10  then  nominal demand = 30 + 24 × (10 − price) / 10
If price ≥ 10  then  nominal demand = 30 × (10 / price

The marginal benefit of advertising decays exponentially.

advertising boost = 1 − ½ exp(−signs)

And the environment effect is as follows:

If hot  then  environment effect = 2.0
If sunny  then  environment effect = 1.0
If there is construction on the street  then  environment effect = 0.1
If cloudy  then  environment effect = 1.0 − probability of rain
If it rains  then  environment effect = 0.0

The total demand is the product of the factors.

total demand = nominal demand × (1 + advertising boost) × environment effect

with an exception noted below.

Based on these formulas, you can calculate the optimal inputs for each weather report. If it’s cloudy, you need to take the probability of rain into account, because if rain actually falls, then nobody will buy any lemonade.

When we played this game as kids, we found the optimal values by a simple gradient descent. Since the demand graph is convex for non-cloudy days, gradient descent does find the optimal values. For cloudy days, we just flailed around.

The exception to the demand formula is that if there is construction on the street, then there is a 50% chance that the street crews will buy all your lemonade. We figured out that the way to make a killing was to jack up the price of lemonade as high as the program will let you ($1.00), spend nothing on advertising, and make a ton of lemonade. If you’re lucky, then the street crews will buy all your lemonade at full price, and you are suddenly rolling in money.

We didn’t realize it at the time, but when we played the game, it was basically just gambling on construction workers.

Bonus chatter: Some time ago, my daughter and her friend made signs for their lemonade stand. The first sign:

Lemonade $1.44

The second sign:

Pay extra get real lemonade


Discussion is closed.

Feedback usabilla icon