Sub topic 3
Expected value: the average worth of a gamble
This chapter assumes you know basic probability (chance as a fraction or percentage, dice odds), have played a range of games, and can read short Python examples. It builds on the previous chapter's vocabulary of outcomes and stakes. Here you will turn a gamble into one number, learn what that number tells you, and learn where it misleads.
What expected value measures
Expected value (EV) is the probability-weighted average of a gamble's outcomes. If you could repeat the same gamble an enormous number of times, EV is the average result per attempt.
To compute it, multiply each outcome's value by its probability and add the products:
EV = p1 × v1 + p2 × v2 + ... + pn × vn
The probabilities must sum to 1. Values can be negative. A loss is a negative number, and a cost you pay to enter the gamble belongs in the outcome as well.
EV is useful to a designer because it puts different choices on one scale. A guaranteed 10 gold and a coin flip between 25 gold and a 2 gold loss are different experiences, but both have an EV you can compare.
A first calculation
The risky option below pays 25 half the time and loses 2 the other half. The safe option pays 10 every time.
def expected_value(outcomes):
# outcomes: list of (probability, value) pairs whose probabilities sum to 1
return sum(p * v for p, v in outcomes)
safe = [(1.0, 10)]
risky = [(0.5, 25), (0.5, -2)]
print(expected_value(safe)) # 10.0
print(expected_value(risky)) # 11.5The risky option works out to 0.5 × 25 + 0.5 × (−2) = 12.5 − 1 = 11.5. It is worth 1.5 more than the safe option on average. No single attempt ever pays 11.5. The number describes the long-run average, not any one result.
Why EV matters when you design
A designer uses EV in three main ways.
- Comparing options. If two choices in the same game have very different EVs, one of them is probably dominant, and the other will rarely be chosen. The chapter on dominant strategies returns to this.
- Pricing risk. If a rare, powerful reward exists, EV tells you how much it adds to the average. A 2% chance of a 500-point jackpot adds 10 points of EV, the same as a guaranteed 10.
- Checking intent. If you want a risky option to feel like a fair trade for a safe one, you can set its EV near the safe option's. If you want risk to be rewarded, you set it a little higher.
The third use is worth slowing down on. A risky option with exactly the same EV as the safe one is a neutral choice. It becomes attractive only to players who enjoy variance. A risky option with a higher EV pays players for accepting uncertainty. A risky option with a lower EV charges them for it, which can be a deliberate design choice but needs another reason for players to take it, such as a unique effect.
Worked example: a treasure chest
Suppose a player can open a chest by paying 3 gold for a key. The chest holds one of these results:
| Result | Probability | Net value (gold) |
|---|---|---|
| Empty | 0.50 | −3 |
| Small coins | 0.30 | +2 |
| Gem | 0.15 | +12 |
| Artifact | 0.05 | +40 |
The net value already subtracts the 3-gold key. The probabilities add to 1.00. The EV is:
- 0.50 × (−3) = −1.5
- 0.30 × 2 = 0.6
- 0.15 × 12 = 1.8
- 0.05 × 40 = 2.0
The sum is 2.9 gold per chest. Each key is worth about 2.9 gold to the player, so the average player profits from opening chests. If chests are plentiful, that is a source of inflation in your economy. If you wanted chests to be a mild gold sink, you would raise the key price or lower a payout until EV falls slightly below zero.
def expected_value(outcomes):
return sum(p * v for p, v in outcomes)
chest = [(0.50, -3), (0.30, 2), (0.15, 12), (0.05, 40)]
assert abs(sum(p for p, _ in chest) - 1.0) < 1e-9
print(round(expected_value(chest), 2)) # 2.9The assertion is a habit worth keeping. Probabilities that do not sum to 1 are the most common cause of a wrong EV, and the error is silent.
EV does not describe spread
Two gambles can have the same EV and feel completely different. Compare a guaranteed 10 with a 10% chance of 100 and a 90% chance of 0. Both have EV 10. The first is certain and the second is a lottery.
EV is blind to this spread. The next chapter introduces variance, which measures it. The code below previews the idea by computing both numbers for the original example.
def expected_value(outcomes):
return sum(p * v for p, v in outcomes)
def variance(outcomes):
mean = expected_value(outcomes)
return sum(p * (v - mean) ** 2 for p, v in outcomes)
safe = [(1.0, 10)]
risky = [(0.5, 25), (0.5, -2)]
print(variance(safe)) # 0.0
print(variance(risky)) # 182.25The risky option's higher EV is only 1.5 points above the safe one, while its variance is 182.25. A designer who looks only at EV would call these nearly equal. A player would not.
Common errors
Ignoring the cost of entry
Many gambles cost something to enter: a key, an action, a turn, a resource. If you compute EV only from the payouts and forget the cost, every gamble looks profitable. Include the cost as part of each outcome, as the chest example does, or subtract it from the final EV.
Treating non-numeric outcomes as zero
Some outcomes do not have an obvious number: a stronger enemy appears, a card goes to the discard pile, the player loses a turn. To compute EV, you have to convert them to a common unit. Common choices are gold, health points, or turns of progress. The conversion is a design judgment, and it is where most EV analysis goes wrong. Write the exchange rate down so others can challenge it.
Mixing units across outcomes
If one outcome is measured in gold and another in health, adding them gives a meaningless number. Convert everything to one unit first.
Assuming one attempt behaves like the average
EV is a long-run statement. A player who opens one chest will see a −3, +2, +12, or +40, never 2.9. If a game gives players only a handful of attempts, the actual results spread widely around EV, and a positive-EV gamble may still lose money for many players.
Assuming the value of a unit is constant
Gaining 10 gold when you have 5 is not the same as gaining 10 gold when you have 5,000. When a resource has decreasing or increasing worth to the player, raw EV misjudges the choice. Players near elimination often value a small survival chance far more than the EV of a bigger gain. If this matters, convert outcomes into how much they help the player win, not into raw quantities.
Forgetting dependent probabilities
If a draw removes a card from the deck, the next draw has different odds. Computing EV with fixed probabilities for sampling without replacement gives wrong answers. Recompute the probabilities after each draw or enumerate the cases.
Using EV to compare stopping rules
EV also works for sequences of choices. In a push-your-luck game, a player rolls repeatedly and decides when to stop. The decision to stop or continue can be analyzed by comparing the EV of one more roll against the current pot.
Consider a die where rolling a 1 loses the whole pot, and any other roll adds its value. With a pot of P, one more roll has this EV change:
- 1/6 chance of losing P, so −P/6
- 5/6 chance of an average gain of (2 + 3 + 4 + 5 + 6) / 5 = 4, so +(5/6) × 4 = 3.33
Rolling again has positive EV while 3.33 > P/6, that is, while P < 20. Beyond a pot of 20, the average player loses by continuing. The break-even point is 20.
You can check this with a simulation. The next program plays many turns for several banking thresholds.
import random
def play_turn(threshold, rng):
# Roll a six-sided die repeatedly. Rolling a 1 loses the whole pot.
# Otherwise add the roll to the pot and stop (bank) once it reaches the threshold.
pot = 0
while pot < threshold:
roll = rng.randint(1, 6)
if roll == 1:
return 0
pot += roll
return pot
def average_score(threshold, turns=100_000, seed=1):
rng = random.Random(seed)
return sum(play_turn(threshold, rng) for _ in range(turns)) / turns
for threshold in (5, 10, 20, 40):
print(threshold, round(average_score(threshold), 2))The output varies slightly with the Python version's random generator, but the averages should peak around thresholds near 20 and fall off on either side. Note that the pot can overshoot the threshold, because a roll adds up to 6 before the check. The simulation therefore finds the best stopping point for the whole turn, which the one-step calculation above approximates.
EV as a design check
A practical workflow looks like this:
- List the outcomes of the choice and their probabilities.
- Convert each outcome into one shared unit, including entry costs.
- Verify that the probabilities sum to 1.
- Compute EV and compare it with the alternatives the player has.
- Decide whether the gap matches your intent: neutral, rewarded, or charged.
- Look at variance and at how many attempts a player gets before trusting the EV.
Summary of the key ideas
- EV is the probability-weighted average of outcomes, including negative ones and entry costs.
- It compares choices on one scale and shows whether a risk is rewarded, neutral, or charged.
- It does not describe spread, and it only predicts results over many attempts.
- Most errors come from wrong probabilities, mismatched units, and forgotten costs.
Exercise
A player pays 4 gold to draw one card. The card gives +1 gold with probability 0.6, +8 gold with probability 0.3, and +20 gold with probability 0.1. These payouts are before the entry cost. What is the net expected value of a draw? Is the draw worth taking on average?
Show answer
Net values are 1 − 4 = −3 (0.6), 8 − 4 = +4 (0.3), and 20 − 4 = +16 (0.1). EV = 0.6 × (−3) + 0.3 × 4 + 0.1 × 16 = −1.8 + 1.2 + 1.6 = 1.0 gold. The draw is worth +1 gold on average, so it is mildly profitable. Because 60% of draws lose gold, many players will still lose on any single try.
Exercise
A designer says, "Option A pays 50 with probability 0.2 and 0 otherwise. Option B pays 9 for certain. They are about equal, so players will choose them equally often." Compute both EVs and explain what the designer has overlooked.
Show answer
EV of A = 0.2 × 50 = 10. EV of B = 9. The EVs are close, but A has a much larger spread: it pays nothing 80% of the time. The designer has overlooked variance and player preference. Risk-averse players will favor B, and players chasing a big payoff will favor A, so the split depends on more than EV.
Exercise
In the dice game from this chapter, the pot is 12 and the player considers one more roll, where a 1 loses the pot and other rolls add their face value. What is the EV change from rolling, and should a player who maximizes average score roll?
Show answer
Losing the pot has probability 1/6 and costs 12, which is −2. A non-1 roll has probability 5/6 and averages +4, which is +3.33. The change is 3.33 − 2 = +1.33, which is positive, so the player should roll again. At a pot of 20 the change is 3.33 − 3.33 = 0.