abelsiqueira / DiceRolls.jl

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

DiceRolls.jl

This package defines dice and operations with them.

MPL-2.0 License GitHub Travis CI [Coveralls]() Documentation Documentation


This package defines dice and some operations with them. We recommend looking into the docs for a better description of what you can do. As a simple example, here is the distribution of the tradicional ability score roll on Dungeons and Dragons, i.e., rolling 4 six-sided dice, removing the lowest and summing the result.

v, f = DiceRolls.histogram(drop(4d6), normalize=true)
Plots.bar(v, f, size=(400,300), leg=false)
xticks!(v)

Another example is to roll two four-sided dice, subtract 1 from each, and multiply the result.

v, f = DiceRolls.histogram((1d4 - 1) * (1d4 - 1))
Plots.bar(v, f, size=(400,300), leg=false)
xticks!(v)

This example can be found in the examples folder.