Dice language

Core rolls

These cover the bread-and-butter TTRPG rolls—use them for attacks, saves, checks, and ability generation.

  • Basic: <count>d<faces> - 1d20, 3d8, 6d6
  • Advantage / disadvantage: adv, dis - d20 adv + 5, d20 dis
  • Keep / drop:
    • kh N keep highest, kl N keep lowest
    • dh N drop highest, dl N drop lowest
    • Example: 4d6 dl 1, 3d20 kh 1
  • Rerolls:
    • rr N reroll matching results until they change
    • ro N reroll once
    • Example: 2d6 rr 1 rr 2, 4d6 ro 1
4d6 dl 1          # ability score roll
3d20 kh 1 + 7     # triple advantage, keep highest. think elven accuracy
6d6 rr 1 rr 2     # reroll 1s and 2s until different

Attacks and crits

Add attack when the d20 roll is an attack check; that unlocks crit awareness and the .crit flag on named rolls. Pair it with on-crit modes to describe how damage scales.

  • Mark an attack: add attack to a d20 roll. The engine preserves the natural d20 so you can reference it later.
  • Crit range: critX..Y (inclusive, 1-20). Example: crit19..20 for improved crit features.
  • On-crit damage modes (choose how to scale damage):
    • oncrit double_dice — roll damage dice again and add them.
    • oncrit double_all — double the entire damage expression (dice + flat bonuses).
    • oncrit max_second_dice — add the maximum value of the extra dice (good for swingy weapons).
(d20 attack crit19..20 + 7) >= 17 ? 2d6 + 4 : 0
(d20 attack + 6 oncrit double_all) >= 15 ? 2d6 + 4 : 0
((d20 adv attack + 9) >= 16 ? 1d10 + 5 : 0) ^ 2   # Extra Attack at level 5

Arithmetic, logic, and ternary

Use math to stack bonuses, logic to gate effects, and the ternary to model “hit-or-miss” or “save-for-half” rules.

  • Arithmetic: +, -, *
  • Comparisons: >, <, >=, <=, == return 1 (true) or 0 (false).
  • Logic operators: & (and), | (or), ! (not).
  • Ternary: condition ? then : else (else defaults to 0). Great for branching damage or conditional riders.
  • Repeat: ^ repeats and sums an expression. Example: (1d6)^3 rolls 1d6 three times and adds the results.
(d20 + 6) >= 15 ? 2d6 + 4 : 0                 # hit-or-miss damage
(d20 + 8) >= 16 ? 3d6 + 4 : (3d6 + 4) / 2     # save-for-half fireball
(4d6 dl 1)^6                                 # six ability scores

Named rolls and properties

  • Bind once: <roll> as <name> — the left side must evaluate to a single dice (e.g., d20 attack, 1d8, 3d6 kh 1). You cannot bind full expressions like (d20 + 5); bind the roll, then add math later.
  • Properties:
    • <name>.total - final total including modifiers if any
    • <name>.roll - natural roll for that binding
    • <name>.crit - 1 if the attack crit, else 0 (only valid on attack bindings)
d20 attack as atk ? (atk.total + 5) >= 16 ? 1d8 + 4 : 0

Commands (type in a cell or simple mode)

  • let <name> = <expr> - create an alias. Example: let smite = 2d8.
  • analyze <expr> - show a PMF for one or more comma-separated expressions.
    Example: analyze 3d6, 2d20 kh 1 + 5

Need character data? Use the UI “Import from D&D Beyond” form; imports are handled outside notebook cells.

Comments

  • Start a line with # to leave a note. Comments are ignored when rolling or analyzing.