Probabilities/Statistics
FR ES

Defeat the Game Master

Seven adventurers in a tavern learn the foundations of probability through dice — uniform distributions, expectation, variance, and the gambler's dungeon.

· 3 min read

Let’s Make Introductions!

The narrative unfolds in a tavern where seven adventurers gather: the Ranger (a versatile but overconfident leader), the Barbarian (a combat-loving warrior), the Elf (carefree and eccentric), the Dwarf (money-obsessed and mathematically skilled), the Rogue (a master thief), the Magician (book-learned but limited magical abilities), and the Ogre (primitive but good-natured).

The Rules of the Game

The Magician produces 14 dice and introduces foundational probability concepts through three axioms:

P(E)[0,1]for any event E\mathbb{P}(E) \in [0,1] \quad \text{for any event } E

P(Ω)=1\mathbb{P}(\Omega) = 1

P(iIEi)=iIP(Ei)\mathbb{P}\left(\bigcup_{i\in I} E_i\right) = \sum_{i\in I} \mathbb{P}(E_i)

She explains three parameter categories:

The Law of the Die

The discrete uniform distribution ensures “each outcome has an equal probability for each mode in a finite set.”

For a fair die with 6 faces:

E(X)=6+12=3.5\mathbb{E}(X) = \frac{6+1}{2} = 3.5

m(X)=3.5m(X) = 3.5

V(X)=621122.91V(X) = \frac{6^2-1}{12} \approx 2.91

No mode exists (all faces equally probable).

For a coin flip: each side has probability 12\frac{1}{2}.

Expectation: Where Results Cluster

The expectation (or mean) of a discrete random variable XX with values x1,x2,,xnx_1, x_2, \ldots, x_n and respective probabilities p1,p2,,pnp_1, p_2, \ldots, p_n is:

E(X)=i=1nxipi\mathbb{E}(X) = \sum_{i=1}^n x_i \cdot p_i

For a fair six-sided die, each face has probability 16\frac{1}{6}, so:

E(X)=116+216+316+416+516+616=216=3.5\mathbb{E}(X) = 1 \cdot \frac{1}{6} + 2 \cdot \frac{1}{6} + 3 \cdot \frac{1}{6} + 4 \cdot \frac{1}{6} + 5 \cdot \frac{1}{6} + 6 \cdot \frac{1}{6} = \frac{21}{6} = 3.5

Variance: The Spread of Fortune

The variance measures how spread out values are around the mean:

V(X)=E[(XE(X))2]=E(X2)[E(X)]2V(X) = \mathbb{E}[(X - \mathbb{E}(X))^2] = \mathbb{E}(X^2) - [\mathbb{E}(X)]^2

For a uniform distribution on {1,2,,n}\{1, 2, \ldots, n\}:

V(X)=n2112V(X) = \frac{n^2 - 1}{12}

The standard deviation σ=V(X)\sigma = \sqrt{V(X)} returns to the same units as XX.

The Dungeon

Following tavern chaos resulting in their imprisonment, the adventurers face a locked steel door. The Barbarian attempts a disadvantage roll (rolling twice, keeping the lower result) to break free.

For two independent rolls X1X_1 and X2X_2, the minimum M=min(X1,X2)M = \min(X_1, X_2) has distribution:

P(Mk)=1P(X1>k)P(X2>k)=1(nkn)2\mathbb{P}(M \leq k) = 1 - \mathbb{P}(X_1 > k) \cdot \mathbb{P}(X_2 > k) = 1 - \left(\frac{n-k}{n}\right)^2

This shifts the expected outcome downward — disadvantage makes heroic feats significantly harder to achieve, as the Barbarian discovers to his frustration.

Code Example

import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

# Fair six-sided die
n_faces = 6
die_values = np.arange(1, n_faces + 1)
die_probs = np.ones(n_faces) / n_faces

mean = np.sum(die_values * die_probs)
variance = np.sum((die_values - mean)**2 * die_probs)

print(f"Mean: {mean:.2f}")       # 3.50
print(f"Variance: {variance:.2f}")  # 2.92

# Simulate n rolls
n_rolls = 100_000
rolls = np.random.randint(1, n_faces + 1, size=n_rolls)

plt.figure(figsize=(10, 5))
plt.hist(rolls, bins=n_faces, range=(0.5, n_faces + 0.5), density=True, alpha=0.7, label='Simulated')
plt.hlines(1/n_faces, 0.5, n_faces + 0.5, colors='red', label='Theoretical')
plt.xlabel('Die Face')
plt.ylabel('Probability')
plt.title('Uniform Distribution: Fair Die')
plt.legend()
plt.grid(ls='--')
plt.show()

# Disadvantage: roll twice, keep lower
roll1 = np.random.randint(1, n_faces + 1, size=n_rolls)
roll2 = np.random.randint(1, n_faces + 1, size=n_rolls)
disadvantage = np.minimum(roll1, roll2)

print(f"\nWith disadvantage:")
print(f"Mean: {disadvantage.mean():.2f}")   # ~2.53

Bibliography