I'm running a new D&D 5e campaign soon and I'd like to try rolling for stats with some guardrails. Doing some test throws at the table, I liked the look of rolling 6d6, then dropping the highest and two lowest rolls. It seems like this would generate a similar median to 4d6 (highest 3), but with a tighter distribution. However, I couldn't figure out how to model this in AnyDice.

This would be really easy to do with the "middle" function if you could just get it to round dice positions up instead of down, however I'm interested in any solution.


2 Answers 2



"... Teach a man to fish, ..."

In the documentation, section Introspection, the @ operator is described as the "access" operator:

you can retrieve individual numbers stored inside a value. You can either provide the position of a single value to retrieve, or a sequence of positions, in which case the retrieved values are summed.

6d6 is a "collection of dice", and in that subsection it says:

When accessing collection of dice, the dice will be order from highest value to lowest value. So 1@3d6 will select the highest rolled value, while 3@3d6 will select the lowest rolled value. {1,2}@3d6 will sum the highest two of the rolled values, discarding the lowest rolled value.

That means to achieve what you have described, you can write {2,3,4}@6d6, which means: "drop the highest result, sum the 2nd, 3rd and 4th highest values and discard the rest."


... doing this and comparing it with {1,2,3}@4d6 (4d6 drop lowest), you will find that the average result is a good bit lower, while being only marginally tighter:

enter image description here

  • 6
    \$\begingroup\$ This is actually a better answer than mine, since it translates the desired rolling behavior directly into code, rather than relying on the middle function's semi-arbitrary rounding behavior to produce the desired result. \$\endgroup\$ Feb 15, 2019 at 19:59
  • \$\begingroup\$ @RyanThompson, much respect for being willing to recognize a better answer. \$\endgroup\$ Feb 16, 2019 at 3:35

The middle function already does what you want

In testing, it looks like the dice are sorted in descending order when selecting the middle. This means that [middle 3 of 6d6] should be exactly what you want: the 2nd, 3rd, and 4th dice after sorting all 6 dice from highest to lowest, thus dropping the 1st (highest) die as well as the 5th and 6th (two lowest) dice.

To convince yourself that the middle function works like this, try [middle 1 of 2d6]. You'll see that the resulting distribution is biased in favor of larger values, which means it is selecting the higher of the two rolls.

Regardless, just in case you want the alternate middle that rounds dice positions up rather than down, we can easily do this by modifying the standard middle function, which looks like this:

function: middle NUMBER:n of DICE:d {
 if NUMBER = #DICE { result: DICE }

 if NUMBER = 1 { result: (1 + (#DICE - 1) / 2) @ DICE }

 FROM: 1 + (#DICE - NUMBER) / 2
 result: {FROM..TO}@DICE

All we need to do is add an additional 1 to each place where a number is divided by 2, to change rounding down into rounding up:

function: altmiddle NUMBER:n of DICE:d {
 if NUMBER = #DICE { result: DICE }

 if NUMBER = 1 { result: (1 + (#DICE) / 2) @ DICE }

 FROM: 1 + (#DICE - NUMBER + 1) / 2
 result: {FROM..TO}@DICE

With these functions defined, we can run the following:

output [middle 3 of 6d6] named "Middle, positions rounding down"
output [altmiddle 3 of 6d6] named "Middle, positions rounding up"

You'll notice that the one using middle has a higher average, which means it's dropping more low dice than high ones.

  • \$\begingroup\$ I can confirm that dice are in ascending order: it’s in the Introspection section of the documentation \$\endgroup\$
    – Dale M
    Feb 15, 2019 at 10:44
  • \$\begingroup\$ Thanks so much. I read the definition of middle and was just assuming ascending, so I didn't even try it! However, I appreciate the COMPLETE answer anyway in case I do some other tweaking. \$\endgroup\$ Feb 15, 2019 at 13:52
  • \$\begingroup\$ @DaleM You mean descending order, right? (i.e. highest first) \$\endgroup\$ Feb 15, 2019 at 17:03

You must log in to answer this question.

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