# How can I model Burning Wheel probabilities in AnyDice?

I have a basic intuition about dice in Burning Wheel, but it's handy to be able to look at actual probability distributions to hone your intuition. Especially since important rolls can involve exploding dice or rerolls, which both complicate the mental math a bit.

How can I represent Burning Wheel rolls, including open-ended dice and rerolls, in AnyDice?

Since this question calls for AnyDice mastery rather than deep understanding of BW as a system, here's a quick summary of what we need to model.

Burning Wheel uses a dice-pool system. A test involves rolling a set of d6s. For each die rolled:

• Black shade ability (typical): 4-6 is a success
• Gray shade ability: 3-6 is a success
• White shade ability: 2-6 is a success

Adding up the successes gives you the total success number, which is then compared against the Obstacle to determine overall success or failure.

(For example, if I roll 4D vs. Ob 2, that means I want to roll 4d6, count the number that come up 4+, and then I've won the roll if I got at least two successes total.)

Additionally, you can spend character resources for these special tricks:

• For a Fate point, you can make a roll "open-ended," so any sixes rolled will give you an extra die to throw in. Those extra dice also explode, &c., &c.
• A Deeds point or Call-On allow a player to pick up all failed dice and reroll them.
• (Here's the corner case: if you explode dice first and then reroll failures, only the original failed dice count; just discard any extras that don't count as successes.)
-
I cannot use this as an answer directly, as you ask specifically about AnyDice. However, if you know a little Ruby, I think my gem `games_dice` can model these probabilities. Docs: rubydoc.info/gems/games_dice/0.3.10/frames – Neil Slater Jan 3 '14 at 13:35

AnyDice handles exploding dice in a peculiar fashion that's poorly-suited for roll-and-count dice pools. I have cobbled together a somewhat inelegant solution, but it appears to work correctly.

Here's the link to the program.

Instead of using dice in the usual manner, I've created several functions that, given parameters of a die, return its output, i.e. the number of successes it has produced.

``````function: roll ROLL:n threshold T {
if ROLL >=T {result: 1}
result: 0
}

function: rollexploding ROLL:n threshold T{
if ROLL =6 {result: 1+[rollexploding 1d6 threshold T]}
result: [roll ROLL threshold T]
}

function: rerollfailures ROLL:n threshold T{
if ROLL < T {result: [roll 1d6 threshold T]}
result: [roll ROLL threshold T]
}

function: rerollthenexplode ROLL: n threshold T {
if ROLL < T {result: [rollexploding 1d6 threshold T]}
result: [rollexploding ROLL threshold T]
}
``````

Then I made a wrapper function that would figure out which of these functions to call, and handle requests for multiple dice being rolled:

``````function: wrapper DICE:n threshold T explode E reroll R{
RES:0
loop N over {1..DICE} {
if E & R {RES: RES+[rerollthenexplode 1d6 threshold T]}
else {if E {RES:RES+[rollexploding 1d6 threshold T]}
else {if R {RES:RES+[rerollfailures 1d6 threshold T]}
else {RES:RES+[roll 1d6 threshold T]}
}
}
}
result:RES
}
``````

Finally, I made a bunch of functions that simplify input by providing pre-determined combinations of parameters. I'll provide only 3 of them here:

``````function: b DICE:n{
result:[wrapper DICE threshold 4 explode 0 reroll 0]
}

function: be DICE:n{
result:[wrapper DICE threshold 4 explode 1 reroll 0]
}

function: gr DICE:n{
result:[wrapper DICE threshold 3 explode 0 reroll 1]
}
``````

To use it, type things like `output [b 4]`

-
This one seems to actually work for all the use cases I've tested! Hurrah! – Alex P Jan 12 '14 at 7:31

A combination of AnyDice functions can get you Burning Wheel dice probabilities.

AnyDice has an `explode` function that you can use like this:

``````output 3d [explode d6]
``````

That will give you an approximation of standard Burning Wheel dice behaviour. (It's only an approximate because AnyDice will only look for explosion of the same die twice; however, you can configure that to higher to get a closer approximation. In my testing though, setting it to 5 didn't alter the output percentages at all when displaying two significant decimals.)

Then you can use the `count` function with a sequence to find how many are successes:

``````output [count {4..6} in 3d [explode d6]]
``````

That would need to be manually edited every time you're altering the exponent or shade though. We can make a function of this for more convenient variable munging:

``````function: EXP burning dice of at least THRESHOLD  {
result: [count {THRESHOLD..6} in EXP d [explode d6]]
}

output [3 burning dice of at least 4]
``````

The function "name" is freeform, so you can alter it for convenience, parametre order, or brevity as you like; I wrote a long natural language–sounding name just to demonstrate that flexibility.

Though personally, I'd like a more natural way to specify shade, so I made some shade-specific functions that use the function above as a helper:

``````function: EXP burning dice of at least THRESHOLD  {
result: [count {THRESHOLD..6} in EXP d [explode d6]]
}

function: EXP black burning dice {
result: [EXP burning dice of at least 4]
}
function: EXP grey burning dice {
result: [EXP burning dice of at least 3]
}
function: EXP gray burning dice {
result: [EXP burning dice of at least 3]
}
function: EXP white burning dice {
result: [EXP burning dice of at least 2]
}

output [3 black burning dice]
output [3 grey burning dice]
output [3 white burning dice]
``````

Allowing for the reroll of failures complicates the functions somewhat. For simplicity I went back to the threshold-number version of the function rather than the "black/grey/white" named functions as a base, and came up with this:

``````function: EXP burning dice of at least THRESHOLD reroll REROLL  {
ROLL: EXP d [explode d6]
SUCCESSES: [count {THRESHOLD..6} in ROLL]
if REROLL = 1 {
UNDERTHRESHOLD: THRESHOLD - 1
FAILURESCOUNT: [count {1..UNDERTHRESHOLD} in ROLL]
FAILURESREROLLED: FAILURESCOUNT d [explode d6]
SUCCESSESFROMREROLL: [count {THRESHOLD..6} in FAILURESREROLLED]
SUCCESSES: SUCCESSES + SUCCESSESFROMREROLL
}
result: SUCCESSES
}

function: EXP burning dice of at least THRESHOLD {
result: [EXP burning dice of at least THRESHOLD reroll 0]
}

output [3 burning dice of at least 4]

function: EXP burning dice of at least THRESHOLD reroll failures {
result: [EXP burning dice of at least THRESHOLD reroll 1]
}

output [3 burning dice of at least 4 reroll failures]
``````

This should work right, but it hasn't been rigorously tested for logic bugs. In any case, it demonstrates how it can be done in general. This could be re-extended to have the natural-language "black/grey/white" functions, but I'll leave that as an exercise for the reader.

-
I played around with this a bit. I think count + explode aren't working together correctly. Compare `output [count {4..6} in 1d6]` and `output [count {4..6} in 1d [explode d6]]` Is there a way to do open-ended sequences? – Alex P Jan 2 '14 at 3:13
@AlexP Interesting... I think I see what it's doing: `explode` is exploding the 6s internally and not adding them as extra dice, so `count` never sees the pre-explode 6s. There's probably a way to write a custom `explode` that will expose all the rolls, but I don't have the opportunity right now. The function help docs on AnyDice would be a good place to start though – there is a howto for writing custom versions of `explode` that work differently. – SevenSidedDie Jan 2 '14 at 5:06
Based on further investigation, the count + explode built-ins definitely don't work together correctly (at least, for our purposes). – Alex P Jan 12 '14 at 7:38

Here is a simple way to get an exploding dice that does the right thing

``````DIE: d{0, 0, 0, 1, 1, 2}

function: exp N:n {
if N = 2 { result: 1 + [exp DIE] }
result: N
}

output 1d[exp DIE]
``````
-