# Help with AnyDice Script for a d6 Dice Pool

I need a script for AnyDice to generate some averages for me.

I want to know the average d6 roll for:

• 1 die of a pool of 1 (which I know approaches 3.5)
• highest 1 die of a pool of 2 dice
• highest 1 die of a pool of 3 dice on up to pool of 8 dice

Then I want to see the results for

• average sum of 2 highest dice of a pool of 2 (which I assume would be 7)
• average sum of 2 highest dice of a pool of 3
• average sum of 2 highest dice of a pool of 4 and on up to 8

Then 3 highest dice of a pool of 3 up on to 8.
Then 4 highest dice of a pool of 4 up on to 8.

I am considering a game mechanic where the character has an attribute like Intelligence with two parts (Raw Ability/Skill) where Raw Ability is the sum of a number of dice and Skill increases the pool rolled where you can pick the highest dice.

If your Intelligence was 2/4 you would roll 4 dice and sum the two highest.
With training your Intelligence would increase to 2/5 and you would sum the two highest out of a pool of 5. What I am trying to determine is how much of a bump is gained by adding that extra die to the pool.

• As a quick rule of thumb, the average outcome of a plain Nd6 roll is 3.5×N, while the maximum possible result is obviously 6×N. If you roll (N+M)d6 and take the highest N, the average will approach the maximum as M increases. Thus, for a given ability level, the difference between "minimum skill" and "near-infinite skill" is a factor of 6 / 3.5 = 12 / 7 ≈ 1.7. – Ilmari Karonen Jul 30 '15 at 21:37
• You're asking for a script, but then you also ask for averages; those are not the same. Do you want an any-dice function to simulate these rolls, or do you want to know how to determine the average outcomes of such rolls (ie; a table of data?) – Erik Jul 30 '15 at 22:16
• @Erik: AnyDice will show you both of those. – user17995 Jul 31 '15 at 14:53

## 1 Answer

Basically, just use the [highest X of Y] function in nested loops and label each one using variable-in-string interpolation.

loop ABILITY over {1..4}{
loop SKILL over {ABILITY..8}{
output [highest ABILITY of SKILLd6] named "[ABILITY]/[SKILL]"
}
}


In the results, the table or chart line (depending on what view you use) labeled mean in the summary is the part you're looking for.

• The at least and transposed views are also interesting in this case. The former tells you how likely a character succeeds at a given DC, and the latter tells you the chances of any given result for any given ability/skill. – MrLemon Jul 31 '15 at 8:18