# Reference

## Contents

## Index

`DiceRolls.CompactedComparison`

`DiceRolls.CompositeRoll`

`DiceRolls.Dice`

`DiceRolls.DiceRoll`

`DiceRolls.DropRoll`

`DiceRolls.KeepRoll`

`DiceRolls.Roll`

`DiceRolls.Roll`

`DiceRolls.drop`

`DiceRolls.histogram`

`DiceRolls.keep`

`DiceRolls.prob`

`DiceRolls.roll`

`DiceRolls.roll`

`DiceRolls.rolllist`

`Statistics.mean`

`Statistics.median`

`Statistics.std`

`Statistics.var`

`DiceRolls.@roll_str`

`DiceRolls.CompactedComparison`

— Type`CompactedComparison(r, op, x)`

Stores a comparison between a roll r and a value x. Use `collect`

to collect all the roll values that satisfy that comparison.

`DiceRolls.CompositeRoll`

— TypeA `CompositeRoll`

is a roll where its parts are rolls. This structure is usually used only internally.

`DiceRolls.Dice`

— Type`Dice(sides)`

`Dice`

is the basic structure of the package. It has `sides`

. The traditional RPG dice are predefined: `d4`

, `d6`

, `d8`

, `d10`

, `d12`

, and `d20`

. There is also an additional useful "dice": `coin`

.

`DiceRolls.DiceRoll`

— TypeA DiceRoll is an Roll made only of dice. A sum or product of several dice, for instance.

`DiceRolls.DropRoll`

— TypeA DropRoll is a roll where some of the parts of the internal roll are ignored. See `drop`

for more information.

`DiceRolls.KeepRoll`

— TypeA KeepRoll is a roll where some of the parts of the internal roll are ignored. See `keep`

for more information.

`DiceRolls.Roll`

— TypeA Roll is an abstract type for operations with Dice.

`DiceRolls.Roll`

— Method`Roll(d :: Dice)`

Create a Roll from a single Dice. Usually used internally.

`DiceRolls.drop`

— Method```
drop(r)
drop(r; kind=:lowest, n=1)
```

Drops the lowest part of a roll. Notice that for a `DiceRoll`

, this means dropping the lowest dice in a roll, but for composite dice, it can mean dropping a whole segment. For instance

`drop(4d6)`

will drop the lowest valued dice of the four 6-sided dice rolled. It is equivalent to

```
v = roll.([d6, d6, d6, d6])
sum(v) - minimum(v)
```

On the other hand,

`drop((2d4 - 1) * (2d4 - 1))`

will drop the lowest of the product, i.e., it is equivalent to

```
v = roll.([2d4 - 1, 2d4 - 1])
sum(v) - minimum(v)
```

**keyword arguments**

`kind`

: Either`:lowest`

or`:highest`

to remove either the lowest or highest roll or rolls.`n`

: The number of dice to be removed.

`DiceRolls.histogram`

— Method```
values, frequency = histogram(dice; normalize=false)
values, frequency = histogram(roll; normalize=false)
```

Computes the histogram of a dice or roll. This operation can be intensive because it computes the histogram of its internal parts recursively, so it can slow for complicated rolls.

`DiceRolls.keep`

— Method```
keep(r)
keep(r; kind=:highest, n=1)
```

Keep only the highest part of a roll. Notice that for a `DiceRoll`

, this means keeping the largest dice in a roll, but for composite dice, it can mean keeping a whole segment. See the behaviour of `drop`

for more information.

**keyword arguments**

`kind`

: Either`:lowest`

or`:highest`

to keep either the lowest or highest roll or rolls.`n`

: The number of dice to be kept.

`DiceRolls.prob`

— Method`prob(comparison)`

Compute the probability of the given comparison, e.g., `prod(2d4 > 3)`

.

`DiceRolls.roll`

— Method`roll(d :: Dice)`

Roll the dice `d`

.

`DiceRolls.roll`

— Method`roll(r :: Roll)`

Roll `r`

.

`DiceRolls.rolllist`

— Method```
rolllist(d :: Dice; generator=false)
rolllist(r :: Roll; generator=false)
```

Show all possible rolllist of dice `d`

or roll `r`

. For `DiceRoll`

s this is a list of all dice results. For `CompositeRoll`

s and other `Roll`

s where its parts are made of `Roll`

s.

`Statistics.mean`

— Method`mean(r)`

Compute the mean of a dice or roll.

`Statistics.median`

— Method`median(r)`

Compute the median of a dice or roll.

`Statistics.std`

— Method`std(r)`

Compute the standard deviation of a dice or roll.

`Statistics.var`

— Method`var(r)`

Compute the variance of a dice or roll.

`DiceRolls.@roll_str`

— Macro`@roll_str(str)`

Convenient string macro. Format: <n rolls>#<N>d<faces>+<modifier><mod effect>

<n rolls>, <N>, <modifier>, <mod effect> are optional.

Example:

```
r"2#1d20+6" # Rolls 1d20+6 twice
r"2d20kh1" # Rolls 2d20 and keeps highest
```