How can I calculate probabilities for Shadowrun 5 in Anydice?

In Shadowrun 5E (and 4E too, earlier it was completely different) you roll a 6 sided die for each point of your skill and the relevant attribute. For every 5 or 6 you see you have a hit.

To explain the question in the title:

  • My Magic attribute is 6
  • My Spellcasting skill is 5
  • I have a specialization for Illusion spells for +2

This means I roll 13d6, if as a result I get for example (6, 6, 5, 5, 5, 3, 3, 3, 3, 3, 2, 1, 1) than I have 5 hits.


2 Answers 2


After much experimentation, puzzlement by the way Anydice handles types, and contacting Catlike Coding for help, here's a piece of code that does account for Exploding Dice and Glitches.

How to Use

Just open the link, adjust the number of DICE in your pool, and optionally adjust MAXDEPTH.

The MAXDEPTH variable sets how many recursions of exploding dice are processed. For pools around 13-20 dice, depth shouldn't exceed 2 (and precision doesn't matter as much). For smaller pools you can increase it.

How to Interpret the Results

Positive results mean the listed numbers of success without a Glitch1.
Negative results mean the listed number of hits, but with a Glitch. *Exception: -999** means a Critical Glitch occurred (ones but no hits).

Why the Code's So Complicated

Anydice is geared towards operating on probabilities more than on normal numbers; e.g., there are various places where it expects to receive unrolled dice pools instead of numbers, and workarounds have to be implemented (such as the mysterious-looking override of the explode function). On the bright side, the workarounds were written by Jasper Flick himself.

Likewise, Anydice isn't geared towards splitting a single roll into multiple outputs, thus the hack with using negative values and the special meaning of -999.

Whole Code

In case Anydice is down and you want to read this for reference, or don't want to click the link.

DICE: 13
\Calculate successes for Shadowrun, with Glitch probabilities (ones*2 > hits)\
\A result of -999 means a Critical Glitch (0 hits)\
\Negative results mean X hits but with a Glitch\
\Positive results are numbers of hits\
\MAXDEPTH is how many recursions of Exploding Dice are allowed\
\With high pools, use lower depth (loss of precision, but less risk of timing out)\
\With low pools, you can increase the depth\
\All hail Catlike Coding!\

function: explode N:n plus X {
 if N = 6 { result: [explode d6 plus X + 1] }
 if N = 5 { result: X + 1 }
 if N = 1 {
  if X { result: -X }
  result: -100
 result: X

function: parse ROLL:s {
 ONES: 0
 HITS: 0
 loop N over ROLL {
  if N > 0 { HITS: HITS + N }
  else if N = -100 { ONES: ONES + 1 }
  else if N  HITS {
  if HITS { result: -HITS }
  result: -999
 result: HITS

set "maximum function depth" to MAXDEPTH
D: [explode d6 plus 0]
output [parse DICEdD]

1 Using the 'ones > hits/2' definition of a Glitch. If you play with a different definition, feel free to change the > to a >= in the code.


This doesn't take glitches or exploding dice from Edge use into account, but the following should do what you need:

output [count {5..6} in 13d6]

It shows that you have a 20.67% chance of getting 5 hits, or a 44.8% chance of getting 5 or more hits.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .