You are butting up against a core problem in AnyDice-- the inability to create non-homogeneous dice collections. When you write sort {1d4,1d6,1d6,1d10}
you are not sorting a collection of dice (as you may expect): you are sorting a sequence.
{1d4,1d6,1d6,1d10}
yields {1,2,3,4,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,7,8,9,10}
Sorting this yields, predictably {10,9,8,...,1,1,1,1}
so 1@X + 2@X
is 19
. X
is not a die.
You can turn X
back into a die trivially, by using dX
. Unfortunately, X
is still not a collection of dice and so you can't use the highest N:n of D:d
built-in to solve your problem. In fact, it is impossible to generate a collection of dice consisting of dice of different sizes in AnyDice and so you will have to brute force the logic for this functionality. You can look at the highest of X:n and Y:n
built-in to see sort of where to start. You'll end up with something like:
A:d4
B:d6
C:d6
D:d10
and then a function expecting 4 numbers with a bunch of conditional branches handling the cases where each is larger(see below).
Alternatively, you can sometimes get really close to what you want just by using:
highest of 1d4 and 1d10 + highest 1 of 2d6
which fails when
[lowest of 1d4 and 1d10] > [highest 1 of 2d6]|[highest of 1d4 and 1d10] < [lowest 1 of 2d6]
which is 17.26% of the time according to AnyDice in your test case. The approximation improves the more spread out your die sizes are.
So you can see how awful this is in general, here's the solution for getting the highest two of four dice and summing them:
function: highest two of A:n and B:n and C:n and D:n
{
if A>B {
FIRST:A
if C>B {
if C>A {
FIRST:C
if D>A{ result: D+C}
result: A+C
}
FIRST:A
if D>C{ result: D+A}
result: A+C
}
if D>B {result: D+A}
result: A+B
}
FIRST:B
if C>A{
if C>B{
FIRST:C
if D>B{ result: C+D}
result: C+B
}
if D>C {result: B+D}
result:C+B
}
if D>A {result: D+B}
result: A+B
}
^
|
| Very Ugly D: We do not like it!
and for your example:
output [highest two of d4 and d6 and d6 and d10]
Basically, AnyDice really struggles with Dogs in the Vineyard.