abelsiqueira / DiceRolls.jl

Julia package defining dice and operations with them
Other
9 stars 4 forks source link

Implement conditonal rolls #10

Closed elihunter173 closed 1 year ago

elihunter173 commented 3 years ago

Resolves #9

After some work I have something that I think works. I haven't written any unit tests, implemented show(), or done even much manual testing, but it seems to work from this short example I was using.

using DiceRolls
r = map_roll(coin, val -> val == 0 ? d20 + 1 : coin)
[roll(r) for i=1:100]
histogram(r, normalize = true)

I'd be interested in getting this to a mergeable state if there's interest. The structure might be a little off because this is the first time I've done Julia outside of a Jupyter notebook, but I tried to follow what the library did / what made sense to me.

abelsiqueira commented 3 years ago

Hi @elihunter173, thanks for the PR. I think we have two things to discuss, one is mapping and the other is the conditional roll. Maybe one can be used for the other, but let's ignore that for now.

For the map, what's the description of the roll? Since it's a roll, I try to translate to English. Like, d20+d20 means roll 2 20-sided dices and sum the result. What should map(d20, f) do? And map(2d20, f)? That's important to define what roll and histogram will do.

I will discuss the conditional on the original issue.