5
\$\begingroup\$

So far I was able to figure out most things I needed to do in anydice on my own and with help of various posts in forums, however in this case my math knowledge fails me.

How do I calculate the probability to roll for example "1,1,1,1,1-4,1-4" with 7d6 and such? And how do I code that in anydice?

The problem is based on the Shadowrun dice pool. There if half or more of your dice are a 1 you "glitch" which is a bit more than just failing the test. Successes are counted on number of 5+'s in your pool. If you glitch but don't have any successes it's a critical glitch. So this is basically about the probability of getting a critical glitch.

\$\endgroup\$
0
12
\$\begingroup\$

The problem is based on the Shadowrun dice pool. There if half or more of your dice are a 1 you "glitch" which is a bit more than just failing the test. Successes are counted on number of 5+'s in your pool. If you glitch but don't have any successes it's a critical glitch. So this is basically about the probability of getting a critical glitch.

Well, here's a quick AnyDice script to calculate the odds of that:

function: glitch ROLL:s {
  result: 2*[count 1 in ROLL] >= #ROLL & [count {5,6} in ROLL] = 0
}

output [glitch 7d6]

The way this works is that:

  • The function glitch ROLL:s expects a sequence of numbers as a parameter. (That's what the :s in the definition means.) When given a dice pool like 7d6, AnyDice automatically calls the function for every possible (sorted) sequence of numbers obtainable by rolling the dice, and sums up the results into a single biased die representing the probability of the function returning each of the possible results when called with a random dice roll.
  • In the function, 2*[count 1 in ROLL] >= #ROLL evaluates to true (1) if at least half the numbers in the sequence ROLL are ones, and to false (0) otherwise. Similarly, [count {5,6} in ROLL] = 0 evaluates to true if there are no fives or sixes in ROLL, and to false otherwise. The operator & between them is logical AND: it returns true (i.e. 1) only if both of the expressions around it are non-zero (i.e. not false).

So basically, there's no particularly fancy math here — AnyDice just solves the problem by brute force, testing every possible dice roll to see if it's a critical glitch or not. (There's a little bit of fancy math involved in calculating the probabilities of each sorted outcome of a 7d6 roll, but that all happens automatically behind the scenes.)


Ps. If you'd like to do this in Python instead, you could use e.g. the dice_pool function from this answer, which does the same thing that AnyDice does internally — it generates all possible sorted rolls of an NdX pool and their respective probabilities. You could then just write a simple loop that sums up the probabilities of all the rolls that are critical glitches and outputs that.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks a lot. That solution works perfectly and in the end it was easier to calculate than I realised. \$\endgroup\$
    – Panzer
    Sep 17 '19 at 8:14
  • 1
    \$\begingroup\$ Worth listing out the rough results for Xd6: 1: 17%, 2: 19%, 3: 5%, 4: 5%, 5: 1%, 6: 1%, 7+: <1%. Note that it is a funny result, even numbers have higher chances of failing than the odd number below them e.g.: p(6) > p(5), p(2) > p(1). \$\endgroup\$
    – Cireo
    Sep 17 '19 at 15:39

You must log in to answer this question.

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