Sub topic 3
Expected value: the average worth of a gamble
Assume you know basic probability, dice odds, and how to read short Python programs. This chapter uses those ideas to measure the average result of a risky game choice.
What expected value measures
Expected value is the probability-weighted average of all possible outcomes. It answers this question:
“If the player made this same choice many times, what result would one attempt average?”
Use this formula:
Expected value = probability × outcome, added across all outcomes
A positive outcome can be a reward, such as coins or damage dealt. A negative outcome can be a cost, such as lost health or a failed turn. Include every possible result in the calculation.
Consider two choices:
| Choice | Possible outcomes | Expected value |
|---|---|---|
| Safe | 100% chance of 10 points | 10 |
| Risky | 50% chance of 25 points, 50% chance of -2 points | 11.5 |
The safe choice has an expected value of 10:
1.0 × 10 = 10
The risky choice has an expected value of 11.5:
0.5 × 25 + 0.5 × -2 = 12.5 - 1 = 11.5
The risky choice is better by average points, but only slightly. A single attempt can produce either 25 or -2. Expected value does not predict the result of one attempt. It describes the long-run average.
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.5Using expected value in design
Expected value helps you compare choices that appear different on the surface. A sword that deals 20 damage half the time and misses half the time has an expected damage of 10. A sword that always deals 9 damage has an expected damage of 9. The first weapon has the higher average, but the second is more reliable.
Do not treat the higher expected value as an automatic winner. Players usually care about more than the average. Timing, current health, available resources, and the cost of failure all change the decision.
For example, a risky attack may be sensible when an enemy is almost defeated. The same attack may be poor when missing causes the player to lose a turn. The numerical value of a result depends on the game state.
A decision model
Describe a gamble in four steps:
- List every possible outcome.
- Assign a probability to each outcome.
- Express each outcome as a value.
- Multiply and add to find the expected value.
The probabilities must add up to 1, or 100%. If an outcome is impossible, give it probability 0. If the probabilities are uncertain, record the assumption and test alternatives.
Expected value is especially useful during balance work. It can reveal that a reward is too weak to justify its risk, or that a supposedly risky option is actually the best choice in every situation. After finding the average, examine how widely the outcomes differ. That spread is variance, which explains why two choices with similar expected values can feel very different.
Exercise
A player can take a safe action worth 6 points, or a risky action with a 40% chance of 20 points and a 60% chance of losing 3 points. Which action has the higher expected value?
Show answer
The safe action has an expected value of 6. The risky action has an expected value of 0.4 × 20 + 0.6 × -3 = 8 - 1.8 = 6.2, so the risky action is higher by 0.2 points.