9
\$\begingroup\$

Would anyone that's anydice savvy take a look at this formula and tell if its correct for what I want to do? The idea is that it returns the highest value among the results of rolling three 6-sided dice (3d6) and one 12-sided die (1d12). According to the formula, there's a 75.89% chance that the highst die will be 6 or higher, but it might be much more than that.

function: highest N:n of A:s B:s {
    result: {1..N}@[sort {A, B}]
}

function: highest N:n of A:s B:s C:s {
    result: {1..N}@[sort {A, B, C}]
}
output [highest 1 of 3d6 1d12]
\$\endgroup\$
5
  • 1
    \$\begingroup\$ There is something that is not completely clear to me. My knowledge of anydice is not very strong, but it seems to me that with your code you are checking if 6 is the max die among 1d6, 1d6, 1d6 and 1d12, while your final comment ""but it might be much more than that*" seems to suggest that you may want to compare a 3d6 roll (range 3-18) and a 1d12 roll. \$\endgroup\$
    – Eddymage
    Feb 5, 2023 at 20:56
  • \$\begingroup\$ @Eddymage that would be an entirely different test and function. \$\endgroup\$
    – Trish
    Feb 5, 2023 at 20:57
  • 1
    \$\begingroup\$ @Trish Yes, I agree. The last sentence puzzles me, I don't understand what OP really wants to compute. \$\endgroup\$
    – Eddymage
    Feb 5, 2023 at 21:02
  • \$\begingroup\$ @Eddymage I figured what they might mean: they used the wrong function^^ \$\endgroup\$
    – Trish
    Feb 5, 2023 at 21:22
  • \$\begingroup\$ @Trish Yep, I had the same feeling... A complete answer you gave, indeed! \$\endgroup\$
    – Eddymage
    Feb 5, 2023 at 21:29

1 Answer 1

20
\$\begingroup\$

The math checks out for your code

The 1d12 has 7 sides of value 6 or higher, so for a simple roll of 1d12, having 6 or higher is \$\frac 7 {12} = 58.3\%\$.

1d6 has 1 side of value 6, so \$ \frac 1 6 = 16.67\%\$. But the math to get to the chance of at least a 6 in multiple dice is much simpler than summing up each path that comes up to having a six in it.

The chance for 3d6 & 1d12 to show at least a single 6 (event \$a\$) is the absolute opposite of them showing no 6s (event \$b\$). But these two must by necessity sum up to 1 or 100%.

So we can calculate the following: 100% needs to be the chance of the opposite event plus the chance of the event we actually seek \$1=a+b\$. Due to basic math rules, we can turn that into 100% minus the chance for the opposite event is the chance of the event we seek, or \$1-b=a\$.

As established, the opposite event \$b\$ is 1 to 5 on all dice, which is the product of those chances on every single item that makes up the event. Those chances are \$\frac 5 6\$ for each d6 and \$\frac 5 {12}\$ for a d12 respecively. So: $$1-\left(\left({\frac 5 6}\right)^3\times\frac 5 {12}\right)=1-\frac{24.113}{100}=75.887\%$$

Yes, it checks out, the formula for anydice thus must be correct.

It can't be higher than that, as you have to have 24.113% of cases that have no 6, and that is the case we calculated first. If you get anything different than the about 75%, then your input has to be wrong for the test of at least a single 6 among the 4 dice.

The logic of your code checks out

Let's start with the code.

function: highest N:n of A:s B:s {
    result: {1..N}@[sort {A, B}]
}

function: highest N:n of A:s B:s C:s {
    result: {1..N}@[sort {A, B, C}]
}
output [highest 1 of 3d6 1d12]

The code executes the bottom first. It calls for a function of highest with 2 inputs. The central stance is simply ignored, there is no input of the highest with 3 input lines. The output is the exact same, if it is omitted.

Why? The top function creates an array of the output of four dice treated individually, which then is sorted and checked for the highest element.

Your code is not checking 3d6 vs 1d12

You check the highest result of 1d6, 1d6 1d6, and 1d12. That is precisely what you wrote in the code. If that is not what you want but treat the 3d6 as one item, you require an entirely different setup. A MUCH simpler code does that, and doesn't require custom coding:

output [highest of 3d6 and 1d12]

And as you seem to expect, this code matches your voiced expectation: 98.07% of the results are a 6 or higher on that check.

The math for this also is using just a different chance for the factors we plug in: to have less than 6, you need to have both at most a 5 on the d12, which is \$\frac 5 {12}\$. You also need to have one of the following results on the 3d6: 1-1-1, 1-1-2, 1-2-1, 2-1-1, 1-2-2, 2-1-2, 2-2-1, 1-1-3, 1-3-1, 3-1-1. Those are 10 combinations of \$6^3\$ possible combinations, or a chance of \$\frac {10}{6^3}\$.

$$1-\left({\frac 5{12}*\frac {10}{6^3}}\right)=1-\left(41.6\%*4.6\%\right)=1-1.93\%=98,07\%$$

\$\endgroup\$
1
  • 1
    \$\begingroup\$ @Stef I hope the clarification makes it easier. \$\endgroup\$
    – Trish
    Feb 6, 2023 at 9:52

You must log in to answer this question.

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