Dice Notation

Learn how to write dice notation expressions in RANDSUM. From basic rolls to complex modifiers.

Basic Syntax

RANDSUM uses the standard dice notation format: NdS where N is quantity and S is sides.

Basic Rolls

import { roll } from '@randsum/roller'

// Roll 1d20
roll('1d20')

// Roll 2d6
roll('2d6')

// Roll 4d8
roll('4d8')

Drop Modifiers

Drop lowest or highest dice from your roll:

Drop Modifiers

// D&D ability score: 4d6, drop lowest
roll('4d6L')

// Drop highest (disadvantage)
roll('4d6H')

// Drop 2 lowest
roll('4d6L2')

Advantage and Disadvantage

Common D&D patterns using drop modifiers:

Advantage/Disadvantage

// Advantage: roll 2d20, keep highest
roll('2d20L')

// Disadvantage: roll 2d20, keep lowest
roll('2d20H')

Arithmetic Modifiers

Add or subtract from your roll total:

Arithmetic

// Add modifier
roll('1d20+5')

// Subtract modifier
roll('2d6-1')

// Multiple operations
roll('1d20+3-1')

Reroll Modifiers

Reroll dice matching certain conditions:

Reroll Modifiers

// Reroll 1s
roll('4d6R{1}')

// Reroll results below 3
roll('4d6R{<3}')

// Reroll specific values
roll('4d20R{1,20}')

Exploding Dice

Roll extra dice on maximum results:

Exploding Dice

// Exploding d6
roll('3d6!')

// Each 6 rolls another die

Combining Modifiers

You can chain multiple modifiers together:

Combining Modifiers

// Reroll 1s, then drop lowest, then add 2
roll('4d6R{1}L+2')

// Exploding dice with drop
roll('3d6!L')

Multiple Dice Groups

Roll different dice types in a single expression:

Multiple Groups

// Attack roll + damage
roll('1d20+5', '2d6+3')

// Or in a single string
roll('1d20+2d6+5')