TabletopAssistant / DiceKit

Swift framework for expressing and evaluating dice notation (e.g., d20, 4d6+4, 3d8×10+2), which is commonly used in tabletop role-playing games.
Apache License 2.0
14 stars 1 forks source link

Support min/max expressions #64

Closed brentleyjones closed 8 years ago

brentleyjones commented 9 years ago

Given an expression that can produce multiple results, like Die, we need expressions that produce the min or maximum of that expression. Useful in some systems that on certain conditions, like critical hits, maximize all of the dice rolled.

LoganJohnson commented 9 years ago

End result of this should look something like:

expression = 2 * 2d(20) + 8
let max = expression.max()        // 88
let min = expression.min()        // 10

?

brentleyjones commented 9 years ago

Yes

brentleyjones commented 9 years ago

Except it might only work when wrapping the die. I'm not sure it will know how to look deeper and say to max each expression.

brentleyjones commented 9 years ago

Maybe to support this expressions will have to expose ranges. It can be inferred from the probability mass of the expression it wraps I guess.

LoganJohnson commented 9 years ago

Yeah I was thinking something with the probability mass. It's practically given at that point.

brentleyjones commented 9 years ago

I think probability mass is the best thing to grace this project.

LoganJohnson commented 9 years ago