Open elihunter173 opened 3 years ago
Hi Eli. That's a good idea, I was hoping to do exactly that at some point.
I implemented rolllist
inside rolllist.jl
in the hope of expanding for conditionals later, but I haven't come up with a good solution - not had the time.
I've implemented comparisons, like d20 + 5 > 13
, which creates a CompactedComparison
. You can collect
for a list of rolls that satisfy it or compute its prob
ability.
Notice that that's not a roll, so roll
and histogram
don't work.
Now the question is how we'd do this. What do we want to write, and what output do we want. Is this a roll, or not?
Two possibilities, there can be others:
roll = (d20 + 5 >= 13 ⇒ 2d6 + 1)
or even d20 + 5 >= 13 ? 2d6 + 1 : 0
. (I don't know it the ternaty operator can be reused. This would be useful for a bot.damage_computation(mod, AC, damage)
, and just use rolllist
for that. Unfortunately, this is very specific and would make more sense in a more specific RPG package.
As far as I can tell, there's no way to describe dice rolls where parts of the roll depend on another, so you can't for example express something like a standard attack and damage roll in D&D, where you roll an attack roll against some AC, doing no damage if you don't roll above a certain number, doing some damage if you do. Alternatively you do extra damage on a 20.
My motivation for this is, for my D&D character, I want to see how much damage each of my attacks do in various situations. So I want to say "Roll a d20 + some modifier, if it's higher than this AC, roll these dice to do this much damage." I've been doing that experimentally since computation is cheap and I can approximate the actual results well enough, but I feel like it should be possible to do analytically.