Update: After actually checking how the success mechanic in "Heart: The City Beneath" works, it seems that Dale M's answer is the correct one.
My answer below, and Groody's answer, do both show how to make the OP's code work as presumably intended: counting the number of rolls of 8 or higher after removing some number of the highest rolls. But that's not how the success mechanic in Heart works.
I'll leave my original answer below for completeness, but please note that it's the correct answer to the wrong question. And please go and upvote Dale's answer.
Yeah, that won't work.
The first problem is that the built-in lowest NUMBER of DICE
function returns the sum of the lowest NUMBER
values, not a sequence containing those values. The second problem is that, even if it did return a sequence, trying to apply it to a dice pool like Nd10
would cause AnyDice to sum the returned sequence anyway (to turn it into a single number, and then collect all those numbers into a weighted die).
But you can write your own count VALUES in lowest NUMBER of DICE
function that does what you want. Conveniently, the AnyDice function library contains "do it yourself" examples of both count VALUES in SEQUENCE
and lowest NUMBER of DICE
, and it's not too hard to combine the two:
\ "Do it yourself" examples from AnyDice's function library: \
function: count VALUES:s in SEQUENCE:s {
COUNT: 0
loop P over {1..#VALUES} {
COUNT: COUNT + (P@VALUES = SEQUENCE)
}
result: COUNT
}
function: lowest NUMBER:n of DICE:d {
result: {(#DICE - NUMBER + 1)..#DICE}@DICE
}
\ Combined custom function: \
function: count VALUES:s in lowest NUMBER:n of DICE:s {
COUNT: 0
loop P over {(#DICE - NUMBER + 1) .. #DICE} {
COUNT: COUNT + (P@DICE = VALUES)
}
result: COUNT
}
One practical change I had to make is that I loop over the dice and compare each of them to the values being searched for, rather than the other way around like the AnyDice example implementation of count VALUES in SEQUENCE
does. Also, I had to make the DICE
parameter a sequence, since I can't loop over it otherwise. This means that, when you pass in a dice pool, AnyDice will call the function with every possible (sorted) result of rolling the dice as a sequence and automatically sum the results (which is exactly what you want).
The finished program thus looks like this:
function: count VALUES:s in lowest NUMBER:n of DICE:s {
COUNT: 0
loop P over {(#DICE - NUMBER + 1) .. #DICE} {
COUNT: COUNT + (P@DICE = VALUES)
}
result: COUNT
}
output [count {8, 9, 10} in lowest 1 of 2d10] named "Domain or Skill"
output [count {8, 9, 10} in lowest 2 of 3d10] named "Domain and Skill"
output [count {8, 9, 10} in lowest 3 of 4d10] named "All and Mastery"