Full Dice Expression Language Specification
The complete guide to writing dice expressions in DEL. From simple rolls to complex conditional mechanics.
1. Overview
DEL (Dice Expression Language) is a powerful notation system for expressing tabletop RPG dice mechanics. It supports everything from simple rolls like 1d20 to complex conditional expressions with modifiers, arithmetic, and functions.
Key Point: All arithmetic in DEL uses integer math. Division always rounds down (floors). There are no decimal numbers.
2. Basic Dice Notation
The fundamental building block is NdX where:
- N = Number of dice to roll (optional, defaults to 1)
- d = The literal character d
- X = Number of sides on each die
Each die produces a random integer from 1 to X. The result is the sum of all dice.
| Expression | Meaning |
|---|---|
| d20 | Roll one 20-sided die (implicit 1) |
| 1d20 | Roll one 20-sided die (explicit) |
| 3d6 | Roll three 6-sided dice, sum them |
| 2d10 + 5 | Roll two 10-sided dice, add 5 |
3. Dice Modifiers
Modifiers are appended directly after dice notation (no spaces). They modify how dice are processed.
Processing Order: Modifiers always execute in this fixed order, regardless of how you write them: Reroll -> Explode -> Keep/Drop -> Sort -> Count
Keep & Drop
Select which dice to keep or drop from the roll.
| Modifier | Meaning | Example |
|---|---|---|
| khN | Keep highest N dice | 4d6kh3 |
| klN | Keep lowest N dice | 2d20kl1 |
| dhN | Drop highest N dice | 5d10dh1 |
| dlN | Drop lowest N dice | 4d6dl1 |
Common Uses:2d20kh1 = D&D Advantage (keep higher d20)2d20kl1 = D&D Disadvantage (keep lower d20)4d6kh3 = D&D Ability Scores (roll 4, drop lowest)
Exploding Dice
When a die meets the condition, roll an additional die. This can chain indefinitely.
| Modifier | Meaning | Example |
|---|---|---|
| ! | Explode on max value | 2d6! |
| !N | Explode on exactly N | 4d10!10 |
| !>=N | Explode when condition met | 5d8!>=7 |
Rerolling
Reroll dice that meet a condition.
| Modifier | Meaning | Example |
|---|---|---|
| r=N | Keep rerolling while equal to N | 4d6r=1 |
| ro=N | Reroll once if equal to N | 4d6ro=1 |
| r<N | Reroll while less than N | 6d10r<3 |
r vs ro: r=1 keeps rerolling until no 1s remain.ro=1 rerolls each 1 at most once (you might still get 1s).
Sorting
Sort dice for display (does not affect the sum).
| Modifier | Meaning |
|---|---|
| sa | Sort ascending (low to high) |
| sd | Sort descending (high to low) |
Success Counting
Count how many dice meet a condition instead of summing them.
| Modifier | Meaning | Example |
|---|---|---|
| cs>=N | Count dice meeting condition | 10d10cs>=8 |
| cf<=N | Count failures | 5d10cf<=3 |
Important: When using cs or cf, the expression returns a count instead of a sum.
4. Arithmetic Operators
| Operator | Name | Example | Result |
|---|---|---|---|
| + | Addition | 5 + 3 | 8 |
| - | Subtraction | 10 - 4 | 6 |
| * | Multiplication | 3 * 7 | 21 |
| / | Integer Division | 17 / 5 | 3 |
| % | Modulo (remainder) | 17 % 5 | 2 |
| ^ | Exponentiation | 2 ^ 10 | 1024 |
5. Comparisons
Comparison operators return 1 for true and 0 for false.
| Operator | Meaning | Example | Result |
|---|---|---|---|
| == | Equal to | 3 == 3 | 1 (true) |
| != | Not equal to | 5 != 5 | 0 (false) |
| < | Less than | 3 < 5 | 1 (true) |
| <= | Less than or equal | 5 <= 5 | 1 (true) |
| > | Greater than | 10 > 5 | 1 (true) |
| >= | Greater than or equal | >= 15 | 1 (true) |
6. Conditionals (Ternary)
The ternary operator lets you choose between two values based on a condition.
If the condition is non-zero (truthy), the first value is used. If zero, the second value is used.
| Expression | Meaning |
|---|---|
| 1d20 >= 15 ? 1d8 + 3 : 0 | Hit on 15+, deal damage, else 0 |
| 1d20 == 20 ? 2d8 : 1d8 | Critical hit: double dice on nat 20 |
| 2d20kh1 >= 18 ? 10 : 0 | Advantage roll, 10 points on hit |
7. Built-in Functions
| Function | Description | Example |
|---|---|---|
| min(a, b, ...) | Returns the minimum value | min(2d6, 8) |
| max(a, b, ...) | Returns the maximum value | max(2d6, 8) |
| abs(x) | Absolute value | abs(3 - 10) |
| floor(x) | Round down | floor(7) |
| ceil(x) | Round up | ceil(7) |
| median(a, b, c, ...) | Returns the middle value | median(1d20, 1d20, 1d20) |
Tip: max(2d6, 8) guarantees at least 8 damage.min(10d6, 50) caps damage at 50.
8. Operator Precedence
Operations are evaluated in this order (highest precedence first):
| Priority | Operator | Associativity |
|---|---|---|
| 1 (highest) | Parentheses () | - |
| 2 | Function calls | - |
| 3 | Unary minus -x | Right |
| 4 | Exponentiation ^ | Right |
| 5 | Multiplication * / % | Left |
| 6 | Addition + - | Left |
| 7 | Comparisons == != < <= > >= | Left |
| 8 (lowest) | Ternary ? : | Right |
9. Game System Examples
D&D 5th Edition
| 1d20 + 5 | Attack roll with +5 modifier |
| 2d20kh1 + 3 | Advantage with +3 modifier |
| 2d20kl1 + 3 | Disadvantage with +3 modifier |
| 4d6kh3 | Ability score generation |
| 4d6ro=1kh3 | Generous ability scores (reroll 1s) |
| 1d20 >= 15 ? 1d8 + 5 : 0 | Attack: hit on 15+, deal damage |
World of Darkness / Storyteller
| 10d10cs>=8 | Roll pool, count 8+ as successes |
| 7d10!cs>=8 | Explode on 10s, count successes |
Shadowrun
| 12d6cs>=5 | Roll 12d6, count 5-6 as hits |
Savage Worlds
| 1d6! + 1d8! | Trait die + Wild die, both explode |
| max(1d6!, 1d8!) | Take the better of two exploding dice |
Custom Mechanics
| max(2d6, 8) | Minimum 8 damage guarantee |
| min(10d6, 50) | Roll 10d6, cap at 50 |
| abs(1d6 - 1d6) | Difference between two rolls |
| median(1d20, 1d20, 1d20) | Middle of three d20 rolls |
Ready to Roll?
Try building your own dice expressions in the interactive Builder.
Open Expression Builder