Open Ygg01 opened 7 years ago
This will take some consideration. It's a good feature idea. The main question I have is, to do this will mean additional syntax to the dice DSL. I don't know that there's any standard common notation for this; most games that use exploding dice tend to just apply it as an automatic rule.
Also, do we need to allow specifying what ranges to explode on? I know most games that I've played that use exploding dice tend to explode on the max result (ie. 6 on 1d6), but presumably some games might use others?
The Crit Dice program I've used, only explodes on highest side there is notation d3!
for exploding dice and d3!!
for exploding compounding dice. Also see this. But perhaps there could be more advanced generators.
Personally, I'd have a Dice
struct that only has side for example:
struct Dice {
side: i64
}
Then have a complex dice generator like
struct DiceGenerator {
die: Dice,
number_of_dies: i64,
}
Where Generator
and Dice
implements trait Generator
, which notes when dice generator has finished.
trait Generator {
fn is_finished(&mut self) -> bool;
fn roll(&mut self) -> i64;
}
struct ExplodingDiceGenerator<T:Generator> {
generator: T,
limit: Dice::max(),
}
Then exploding dice is a more complex generator, that terminates when certain limit is met.
Mm. That's a good idea. Possibly though, Die could itself be a Trait, which die types implement, that way we can later implement all kinds of different types of custom dice easily. I already had custom die sequences on the road map (so you can do stuff like Fudge dice as, say, 4d[-1, 0, 1]
.
I think !
is a great idea for the syntax as well; I like that there's existing tools using it, so there's precedent.
And just like that, I've got a rough proof of concept of generic die generators: https://github.com/jarcane/rouler/blob/235483dd039239f84bc46d46aacf0c2bb6176f25/src/random.rs
Any update on this?
Hey, sorry. I have rather got caught up in some personal stuff of late. I actually did get a working implementation for generic dice types (see the generic-dice branch: https://github.com/jarcane/rouler/blob/generic-dice/src/random.rs), but I stalled out at figuring out how to extend the grammar to support the new exploding dice.
I need to do some simulation, where there are exploding dice. I.e. when you roll the highest dice, your dice explode and you roll again. And if your dice roll again, it explodes, etc.