Sub topic 2
Input randomness and output randomness
Prerequisites
This chapter assumes you know expected value, basic dice odds, and how to read short Python functions.
Two places randomness can sit
Randomness can enter a game at two points. Input randomness happens before the player chooses, such as a shuffled card drawn into a hand. Output randomness happens after the choice, such as a die roll that decides whether an attack lands.
Input randomness changes what options the player has. Output randomness changes what happens after the player acts. Designers often use output randomness when they want the choice itself to matter.
Information and agency: knowing the odds
Agency depends on information. A player who knows the odds can compare options. A player who does not know them can only guess. Hidden odds turn a decision into a gamble with unknown stakes. Showing the probability on screen restores the choice, even when the outcome stays random.
How players perceive risk
Players feel losses more strongly than equal gains. This pattern is called loss aversion. Players also misjudge small probabilities. A 10% chance of losing a unit can feel much larger than it is, or much smaller after several lucky rolls. State odds clearly, and keep losses recoverable.
Push-your-luck mechanics and stopping rules
In a push-your-luck mechanic, the player decides when to stop collecting rewards before a risk ends the turn. The stopping rule is the point where the player banks the pot. Simulation can find a good threshold:
import random
def play_turn(threshold, rng):
pot = 0
while pot < threshold:
roll = rng.randint(1, 6)
if roll == 1:
return 0 # a roll of 1 loses the whole pot
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))Run the code and compare the averages. A threshold that is too low leaves points on the table. A threshold that is too high loses the pot too often. The best threshold has the highest average, not the one that feels most exciting.
Exercise
In the simulation, why does raising the threshold eventually lower the average score?
Show answer
Higher thresholds keep the player rolling longer. The chance of rolling a 1 and losing everything keeps adding up. Past some threshold, the extra points per roll no longer outweigh the risk of losing the whole pot.