Supported dice notation - Adventuresmith/dart-dice-parser GitHub Wiki

Supported dice notation

Polyhedral, Fudge, Percentile, D66 Dice

  • 2d6 -- roll 2 dice of 6 sides
  • 4dF -- roll 4 fudge dice (sides: [-1, -1, 0, 0, 1, 1])
  • 1d% -- roll 1 percentile dice (equivalent to 1d100)
  • 1D66 -- roll 1 D66, aka 1d6*10 + 1d6
    • NOTE: you must use uppercase D66, lowercase d66 will be interpreted as a 66-sided die
  • 2d[2,3,5,7]-- roll 2 dice with values [2,3,5,7]

Modifying Roll Results

Exploding Dice: !

4d6! -- roll 4 6-sided dice, explode if max (6) is rolled (re-roll and include new die result in results)

Other examples:

  • 4d6 !=5 or 4d6!5 -- explode a roll if equal to 5
  • 4d6 !>=4 - explode if >= 4
  • 4d6 !<=2 - explode if <=2
  • 4d6 !>5 - explode if > 5
  • 4d6 !<2 - explode if <2
  • To explode only once, use syntax !o: 4d6 !o<5

Compounding Dice: !!

Compounding dice are used in Shadowrun, L5R, etc. Similar to exploding dice, but the additional rolls for each dice are added together as a single "roll". The original roll is replaced by the sum of it and any additional rolls.

5d6 !! -- roll 5 6-sided dice, compound if max (6) is rolled (re-roll 6 and add)

  • 5d6 !!=5 or 5d6!5 -- compound a roll if equal to 5
  • 5d6 !!>=4 - compound if >= 4
  • 5d6 !!<=4 - compound if <= 4
  • 5d6 !!>5 - compound if > 5
  • 5d6 !!<3 - compound if < 3
  • To compound only once, use syntax !!o
    • 5d6 !!o<2

Compounding vs Exploding example

For example, exploding 3d6: 3d6! * [6,6,1] is the rolled initially * there's two 6s. roll 2d6 * [2,6] is rolled. * explode again. roll 1d6 * [3] is rolled.

The accumulated rolls are [6,6,1,2,6,3], with a total of 24.

Given those individual d6 rolls, how would the outcome be different if we'd compounded instead? 3d6!!? The total is (24), but the accumulated rolls would look much different.

  • [6 + 2, 6 + 6 + 3, 1] ==> [8,15,1]

Re-Rolling Dice: r

  • 4d4 r2 -- roll 4d4, re-roll any result = 2
  • 4d4 r=2 -- roll 4d4, re-roll any result = 2
  • 4d4 r<=2 -- roll 4d4, re-roll any <= 2
  • 4d4 r>=3 -- roll 4d4, re-roll any >= 3
  • 4d4 r<2 -- roll 4d4, re-roll any < 2
  • 4d4 r>3 -- roll 4d4, re-roll any > 3
  • To reroll only once, use syntax ro
    • 4d4 ro<2

Keeping or Dropping dice: k, kh, kl, -h, -l

  • 3d20 k 2 -- roll 3d20, keep 2 highest
  • 3d20 kh 2 -- roll 3d20, keep 2 highest
  • 3d20 kl 2 -- roll 3d20, keep 2 lowest
  • 4d6 -H -- roll 4d6, drop 1 highest
  • 4d6 -L -- roll 4d6, drop 1 lowest
  • 4d6 -H2 -- roll 4d6, drop 2 highest
  • 4d6 -L2 -- roll 4d6, drop 2 lowest
  • 4d6 ->5 -- roll 4d6, drop any results > 5
  • 4d6 -<2 -- roll 4d6, drop any results < 2
  • 4d6 ->=5 -- roll 4d6, drop any results >= 5
  • 4d6 -<=2 -- roll 4d6, drop any results <= 2
  • 4d6 -=1 -- roll 4d6, drop any results equal to 1
  • NOTE: the drop operators have higher precedence than the arithmetic operators; 4d10-L2+2 is equivalent to (4d10-L2)+2
  • NOTE: drop is not subtraction.
    • 4d6 - 3 -- roll 4d6, subtract 3
    • 4d6 - 2d6 -- roll 4d6, subtract the result of rolling 2d6

Capping / Clamping: C< or C>

  • 4d20 C<5 -- roll 4d20, change any value < 5 to 5
  • 4d20 C>15 -- roll 4d20, change any value > 15 to 15

Scoring dice rolls:

Counting: #

  • 4d6 # -- how many results?
    • For example, you might use this to count # of dice above a target. (5d10 -<6)# -- roll 5 d10, drop any less than 6, count results
  • 4d6 #>3 -- roll 4d6, count any > 3
  • 4d6 #<3 -- roll 4d6, count any < 3
  • 4d6 #>=5 -- roll 4d6, count any >= 5
  • 4d6 #<=2 -- roll 4d6, count any <= 2
  • 4d6 #=5 -- roll 4d6, count any equal to 5

Successes and Failures: #s, #f, #cs, #cf

  • A normal count operation # discards the rolled dice and changes the result to be the count
    • For example, 2d6#<=3 rolls [3,4] then counts which results are <=3 , returning [1]
  • But, sometimes you want to be able to count successes/failures without discarding the dice rolls. In this case, use modifiers #s, #f, #cs, #cf to add metadata to the results.
    • 6d6 #f<=2 #s>=5 #cs6 #cf1 -- roll 6d6, count results <= 2 as failures, >= 5 as successes, =6 as critical successes, =1 as critical failures
    • The above returns a result like: RollSummary(total: 22, results: [6, 2, 1, 5, 3, 5], metadata: {rolled: [6, 2, 1, 5, 3, 5], score: {successes: [6, 5, 5], failures: [2, 1], critSuccesses: [6], critFailures: [1]}})
  • NOTE: discarded dice are not scored
    • 2d20 kh #cf #cs -- roll 2d20, keep the highest, count critical successes & failures. If this rolled [1,18], the 1 is dropped and the result does not record a critical failure.

Arithmetic Operations: +, *, -, (, )

  • (, and ) - parenthesis to force a certain order of operations
  • + - addition is a little special -- the addition could be a sum of ints, or it can be used to aggregate results of multiple dice rolls
    • Addition of integers is the usual sum
      • 4+5
      • 2d6 + 1
    • Addition of roll results combines the results (use parens to ensure the order of operations is what you desire)
      • (5d6+5d10)-L2 -- roll 5d6 and 5d10, and from aggregate results drop the lowest 2.
      • 5d6+5d10-L2 -- roll 5d6 and 5d10, and from only the 5d10 results drop the lowest 2. equivalent to 5d6+(5d10-L2)
      • ((1d6 + 1d8)-L)! -- roll 1d6 and 1d8, drop the lowest result, and explode the remaining die
  • * for multiplication
  • - for subtraction
  • numbers must be integers
  • division is not supported.
⚠️ **GitHub.com Fallback** ⚠️