Sub topic 13
Simulating, playtesting, and tuning
This chapter assumes you know expected value and variance, push-your-luck stopping rules, and how dominant strategies break a choice. You should also be able to read short Python programs. Here you will test a risk-reward mechanic with code and with people, then adjust it using what you find.
Why you need both simulation and playtesting
Simulation and playtesting answer different questions.
- Simulation answers "what do the rules do under a given strategy?" It is fast, cheap, and repeatable. It cannot tell you whether the game is fun, confusing, or stressful.
- Playtesting answers "what do real players do, and how does it feel?" It shows misread odds, ignored options, and frustration. It is slow and noisy, and every session sees only a few dozen random events.
A simulation only plays the strategies you write, so it will not find a trick you did not think of. Players will find it. A playtest of ten turns cannot tell a 10% bust rate from a 15% one, but a simulation of fifty thousand turns can.
A common workflow is to simulate first to find numbers that look sane, then playtest to see whether players behave the way the simulation assumed. Feed the playtest findings back into the next simulation.
Start with a hypothesis and a target
Before you run anything, write down what you expect. A usable target names a behavior and a number:
- "A player who banks at 20 points should win about as often as one who banks at 10."
- "A turn should bust between 25% and 40% of the time under reasonable play."
- "Fewer than 60% of players should pick the safe option every time."
Without a target, any result looks acceptable. Writing the target first also stops you from adjusting the goal to match whatever the numbers turn out to be.
Simulating a push-your-luck turn
The turn below is the dice game from the push-your-luck chapter, with one addition: a bust_faces knob. A roll at or below bust_faces loses the whole pot. With the default of 1, only a roll of 1 busts.
import random
import statistics
def play_turn(threshold, rng, bust_faces=1):
# Roll a six-sided die until the pot reaches the threshold.
# A roll of bust_faces or lower loses the whole pot.
pot = 0
while pot < threshold:
roll = rng.randint(1, 6)
if roll <= bust_faces:
return 0
pot += roll
return pot
def summarize(threshold, turns=50_000, seed=1, bust_faces=1):
rng = random.Random(seed)
scores = [play_turn(threshold, rng, bust_faces) for _ in range(turns)]
mean = statistics.fmean(scores)
stderr = statistics.stdev(scores) / turns ** 0.5
bust_rate = scores.count(0) / turns
return mean, stderr, bust_rate
print("threshold mean +/- bust_rate")
for threshold in (5, 10, 20, 30, 40):
mean, stderr, bust = summarize(threshold)
print(f"{threshold:>9} {mean:5.2f} {stderr:.3f} {bust:.1%}")A few details matter here.
- A seeded
random.Random(seed)makes the run repeatable, so a teammate gets the same numbers. It is also kept separate from the global random state, so other code cannot disturb it. scores.count(0)is a valid bust count because any successful turn banks a positive pot.- The standard error,
stdev / sqrt(turns), tells you how much the mean would wobble if you reran with a different seed. Two thresholds whose means differ by less than about two standard errors should be treated as tied.
Reading the output
Look at three things.
- The shape of the mean. In a game like this, the average score rises as the threshold grows, then falls once the bust rate overwhelms the larger pot. The peak is the best fixed stopping point. A rough calculation puts it somewhere around 20, but trust your own run over that estimate.
- The bust rate. A strategy can be optimal and still bust most of the time. If the best threshold busts 70% of turns, the mechanic may be correct on paper and miserable to play.
- A flat top. If thresholds 15 to 25 score nearly the same, the choice is forgiving. If one threshold is far better than all others, you may have a dominant strategy. Players will find it, and the stopping decision stops being interesting.
Tuning with a design knob
Tuning means changing one parameter and watching a metric move. The next function finds the best threshold for each setting of bust_faces. It reuses summarize and play_turn from the previous block, so run both blocks together.
def best_threshold(bust_faces, thresholds=range(4, 61, 4), turns=20_000):
results = {
t: summarize(t, turns=turns, seed=7, bust_faces=bust_faces)
for t in thresholds
}
best = max(results, key=lambda t: results[t][0])
mean, _, bust_rate = results[best]
return best, mean, bust_rate
for faces in (1, 2, 3):
t, mean, bust = best_threshold(faces)
print(f"bust_faces={faces}: best threshold {t}, "
f"mean {mean:.2f}, bust rate {bust:.1%}")This shows how a knob moves several things at once. Raising bust_faces makes busts more likely, which lowers the best threshold and shortens turns. It also cuts the mean score. If you wanted a higher bust chance without a lower payout, you would need a second knob, such as a bonus for banking. Change one knob per experiment, or you will not know which change caused the effect.
The grid in best_threshold steps by 4, so the answer is only accurate to about that much. Search coarsely first, then rerun a finer grid around the winner.
Playtesting risk and reward
Players are not expected-value maximizers. Your simulation assumes a fixed rule, such as "bank at 20", so it needs a playtest to learn how people actually choose. Prepare these before the session:
- A question for each session. For example: "Do players take the risky card when the safe one has a better average?" A session without a question produces opinions, not evidence.
- A way to record decisions. Log each risky choice, its odds, its outcome, and the player's score position. Paper tally sheets work for tabletop games. Digital games should write structured events.
- A comparison to the simulation. For every logged choice, ask what your simulated strategy would have done.
Compare behavior against the simulation, not only win rates. If the simulation says banking at 20 is best, but players bank at 8 on average, the game has a perception problem, not a math problem. The fix may be clearer odds display, as covered in the information chapter.
Metrics to collect
| Metric | What it tells you | Warning sign |
|---|---|---|
| Risky-option pick rate | How attractive the gamble is | Near 0% or near 100% suggests a dominant option |
| Bust rate per turn | How punishing the risk feels | Far above the target after a few sessions |
| Time to recover from a bust | Whether failure is survivable | Players quit or concede after one bust |
| Score spread between players | How much luck beats skill | Weaker players win as often as stronger ones |
| Decision time | Whether the choice is real | Instant picks every time suggest a solved choice |
Combine this table with direct observation. A player who sighs after every bust tells you something no tally sheet records. Ask players what they were thinking at the moment of a choice, not afterward. Memory favors the dramatic outcomes.
Common errors
- Too few samples. Ten playtest turns look like a pattern but are noise. Use simulation for rates and playtests for behavior.
- Tuning against one strategy. If you only simulate the best fixed threshold, you may miss that a mixed or adaptive strategy beats it. Add at least one adaptive player, such as one who banks sooner when ahead.
- Changing several knobs at once. You cannot attribute the effect, so record each change and its measured result.
- Trusting stated preferences. Players say they want more risk, then play safe. Weigh what they do over what they say.
- Overfitting to testers. Your friends know your game. Include players who have never seen it, because they show how the rules read cold.
- Ignoring seeds. An unseeded simulation gives different numbers every run, and you cannot tell whether a change helped or you got lucky.
Knowing when to stop
Tuning has diminishing returns. Stop when the metrics sit inside the target ranges across several sessions, new testers make the same choices as earlier ones, and no single option dominates. Further tweaks past that point usually trade one imbalance for another. Record the final numbers and the reasoning so the next change starts from evidence.
Exercise
In your simulation, the best fixed threshold has a mean score of 7.1 with a standard error of 0.05. The next best threshold has a mean of 7.0 with a standard error of 0.05. Can you say the first is better? What would you do next?
Show answer
Not with confidence. The gap is 0.1, about one combined standard error (roughly 0.07), so the two thresholds are effectively tied. Rerun both with many more turns, or with a different seed, to see whether the gap persists. If they stay tied, the top of the curve is flat and the choice is forgiving. Then check the bust rates, since two thresholds with equal means can feel very different to play.
Exercise
A playtest shows that 90% of players always bank at 8 points, while your simulation says the best threshold is about 20. Name two possible causes and one change to try for each.
Show answer
One cause is loss aversion: players feel a bust more strongly than they value the larger pot. Try softening the cost of a bust, for example by keeping a small consolation score. Another cause is misjudged odds, because players cannot tell how likely a bust is. Try showing the bust chance or the running pot more clearly. Rerun the playtest after each change separately to see which one moves the average banking point.