[RPG] How to get the highest or lowest values of an irregular dice pool in AnyDice

anydicestatistics

I want to calculate irregular dice pools, such as (2d10, 1d8) in AnyDice, but I'm having difficulties.

What I mean to do is out of a roll of 2d10 and a 1d8, take the highest (or lowest) two values of the three dice and sum them (total 2-20 with highest & total 2-18 with lowest). I.e. d10 => 7, d10 => 4, d8 => 5 results in either 4 & 5 for 9 total (keep lowest) or 7 & 5 for 12 total (keep highest).

I can do this in Troll, by putting sum largest 2 {2d10,1d8}. I would like to translate this to AnyDice, since I prefer it due to the overlapping graph when comparing probabilities, but am having difficulties since the odds don't match when doing output [highest of 2d10 and 1d8].

Best Answer

Take into account that when you pass 2d10 to Anydice, it automatically sums it. Trying to simulate what you wanted the easiest way I found, here's the code:

function: highestsum A:n B:n C:n {
 result: {1,2} @ [sort {A, B, C}]
}

function: lowestsum A:n B:n C:n {
 result: {2,3} @ [sort {A, B, C}]
}

output [highestsum 1d10 1d10 1d8]
output [lowestsum 1d10 1d10 1d8]

You can test it here.

What both functions do, is sum the three dices and then take out the highest or the lowest. Take into account that it's important to use three dices in this code, splitting the two 2d10 in 1d10 and 1d10.

Edit: Improved thanks to Ilmari Karonen

Related Topic