# 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.

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

## 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](02-two-dice.html) · [Next: success](04-success.html).
For a named-game application, see [ordinary D&D ability checks](../cookbook/dnd2014-ability-check.html);
attack-specific natural-face rules must not be assumed for ordinary checks.
