[RPG] Syntax for a unique dice system on Anydice

anydicegame-design

I've been studying and toying with a lot of odd dice systems for a while now, and Anydice has been a great help in understanding the probability effects of different systems. However, I've run into one that, while fun in practice, I have not been able to model in Anydice to better understand its curves.

An example output could be described as

Highest 2 of 2d6 and 3d8

however Anydice doesn't recognize this syntax. I found a similar question from about a year ago with some great answers, but that person was only trying to find the highest single result, while I need the highest two results of an irregular dice pool.

The system is a combination of roll and keep with step dice, with step dice for attributes and number of dice rolled, always keeping 2, for skills. Attributes step up unevenly, so the pool is either made up only from d6, a mixture of d6 and d8, or only d8. In the case of a mixed pool, each type of dice takes up half of it, rounding in favor of the larger die if your pool is odd.

I can figure out how to loop the variables myself though once I can find a way to arrange said variables.

Best Answer

This is actually fairly simple to implement in AnyDice:

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

function: lowest N:n of A:s and B:s {
  LEN: #A + #B
  result: {LEN-N+1 .. LEN} @ [sort {A, B}]
}

These functions assume that you haven't changed the sorting order, which is highest-to-lowest by default. If you reverse it, the "highest" function will start returning the lowest rolls, and vice versa.

You can also easily modify these functions to handle more than two types of dice, as in:

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

function: lowest N:n of A:s and B:s and C:s {
  LEN: #A + #B + #C
  result: {LEN-N+1 .. LEN} @ [sort {A, B, C}]
}

Now for the bad news: these functions can get very slow for large dice pools, because they enumerate all the possible rolls by brute force. The built-in "highest/lowest N of DICE" functions are optimized using clever math to run very quickly even for large numbers of dice, but these aren't. If you try to compute something like [highest 2 of 10d6 and 10d8] using these functions, you'll almost certainly get a time-out error.

Also, it's worth noting that, just like the built-ins, these functions return a single biased die describing the sum of the highest / lowest N values. Thus, for example, [highest 1 of [highest 2 of 1d6 and 1d8]] is not the same as [highest 1 of 1d6 and 1d8]! As far as I know, actually combining e.g. a d6 and a d8 into a single dice pool in AnyDice is simply not possible; you can have biased dice representing any probability distribution you want, and you can have pools of several identical dice, but you can't have different types of dice in the same pool.

On the plus side, unlike the built-ins, these functions work "as expected" also for sequence inputs: for example, [highest 2 of {1,2} and {3,4}] returns 7 = 3+4 as expected, not 10 = 1+2+3+4 like the corresponding built-in [highest 2 of {1,2,3,4}] would(!). (This happens because the built-ins are defined to take a die as their input, not a sequence, and so AnyDice will auto-convert a sequence to a die by summing its values before the function even sees it. I kind of consider that a bug in AnyDice, even if it's technically working exactly as documented.)