Skip to main content

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.

ExpressionMeaning
d20Roll one 20-sided die (implicit 1)
1d20Roll one 20-sided die (explicit)
3d6Roll three 6-sided dice, sum them
2d10 + 5Roll 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.

ModifierMeaningExample
khNKeep highest N dice4d6kh3
klNKeep lowest N dice2d20kl1
dhNDrop highest N dice5d10dh1
dlNDrop lowest N dice4d6dl1

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.

ModifierMeaningExample
!Explode on max value2d6!
!NExplode on exactly N4d10!10
!>=NExplode when condition met5d8!>=7

Rerolling

Reroll dice that meet a condition.

ModifierMeaningExample
r=NKeep rerolling while equal to N4d6r=1
ro=NReroll once if equal to N4d6ro=1
r<NReroll while less than N6d10r<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).

ModifierMeaning
saSort ascending (low to high)
sdSort descending (high to low)

Success Counting

Count how many dice meet a condition instead of summing them.

ModifierMeaningExample
cs>=NCount dice meeting condition10d10cs>=8
cf<=NCount failures5d10cf<=3

Important: When using cs or cf, the expression returns a count instead of a sum.

4. Arithmetic Operators

OperatorNameExampleResult
+Addition5 + 38
-Subtraction10 - 46
*Multiplication3 * 721
/Integer Division17 / 53
%Modulo (remainder)17 % 52
^Exponentiation2 ^ 101024

5. Comparisons

Comparison operators return 1 for true and 0 for false.

OperatorMeaningExampleResult
==Equal to3 == 31 (true)
!=Not equal to5 != 50 (false)
<Less than3 < 51 (true)
<=Less than or equal5 <= 51 (true)
>Greater than10 > 51 (true)
>=Greater than or equal>= 151 (true)

6. Conditionals (Ternary)

The ternary operator lets you choose between two values based on a condition.

condition ? value_if_true : value_if_false

If the condition is non-zero (truthy), the first value is used. If zero, the second value is used.

ExpressionMeaning
1d20 >= 15 ? 1d8 + 3 : 0Hit on 15+, deal damage, else 0
1d20 == 20 ? 2d8 : 1d8Critical hit: double dice on nat 20
2d20kh1 >= 18 ? 10 : 0Advantage roll, 10 points on hit

7. Built-in Functions

FunctionDescriptionExample
min(a, b, ...)Returns the minimum valuemin(2d6, 8)
max(a, b, ...)Returns the maximum valuemax(2d6, 8)
abs(x)Absolute valueabs(3 - 10)
floor(x)Round downfloor(7)
ceil(x)Round upceil(7)
median(a, b, c, ...)Returns the middle valuemedian(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):

PriorityOperatorAssociativity
1 (highest)Parentheses ()-
2Function calls-
3Unary minus -xRight
4Exponentiation ^Right
5Multiplication * / %Left
6Addition + -Left
7Comparisons == != < <= > >=Left
8 (lowest)Ternary ? :Right

9. Game System Examples

D&D 5th Edition

1d20 + 5Attack roll with +5 modifier
2d20kh1 + 3Advantage with +3 modifier
2d20kl1 + 3Disadvantage with +3 modifier
4d6kh3Ability score generation
4d6ro=1kh3Generous ability scores (reroll 1s)
1d20 >= 15 ? 1d8 + 5 : 0Attack: hit on 15+, deal damage

World of Darkness / Storyteller

10d10cs>=8Roll pool, count 8+ as successes
7d10!cs>=8Explode on 10s, count successes

Shadowrun

12d6cs>=5Roll 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