User guide All lessons Cookbook Function reference Open playground

Open this document in the playground · Download source

Modifiers: move the results, not their chances

Part A · L03 · 5–10 minutes · Prerequisite: L02

The situation and question

Our generic task rule adds a fixed +2 modifier to a two-d6 total. How does that bonus change the possible totals? This is a scoped arithmetic component; it does not yet implement any named game's difficulty or exception rules.

Predict

Will +2 make the distribution wider, or move every result two places higher?

Build

An assignment such as modifier = 2 gives a value a name. Later lines can use that name instead of repeating the number. A descriptive name makes a safe editing point—a parameter—easy to find.

total below is a distribution, not one secretly rolled number. modified adds the same fixed number to every possible total. = assigns a name; it does not ask whether two values are equal.

modifier = 2
total = d(6) + d(6)
modified = total + modifier
output("Before the modifier", total)
output("After the modifier", modified)

Before the modifier · DieRoll · mean 7.000

outcome%fracX/36
22.781/361
35.561/182
48.331/123
511.11/94
613.95/365
716.71/66
813.95/365
911.11/94
108.331/123
115.561/182
122.781/361

After the modifier · DieRoll · mean 9.000

outcome%fracX/36
42.781/361
55.561/182
68.331/123
711.11/94
813.95/365
916.71/66
1013.95/365
1111.11/94
128.331/123
135.561/182
142.781/361

Run and read

Before the modifier, the range is 2–12 and the mean is 7. Afterwards, the range is 4–14 and the mean is 9. The old chance of 7, 6/36, is now the chance of 9. No probability changes: only the labels on the numeric results move.

Change one thing

Set modifier = -1. The minus sign makes this a penalty. Check: the range becomes 1–11 and the mean becomes 6.

Try it yourself

Write a one-d8 roll with a named +3 bonus and a descriptive output title. Answer check: assigning bonus = 3, then reporting d(8) + bonus, gives range 4–11 and mean 7.5. Each result still has probability 1/8.

What you now know

Names let you separate a rule's inputs from its calculation. A flat modifier shifts a distribution without changing its shape.

Where next

Previous: two dice · Next: success. For a named-game application, see ordinary D&D ability checks; attack-specific natural-face rules must not be assumed for ordinary checks.

Content ID: L03 · Review status: pilot