Learn R Programming

droll (version 0.1.0)

check: Work with skill checks' probabilities and DCs

Description

These are simple functions that manipulate probabilities and DCs for skill checks. check_prob() calculates the success/failure probability of a check with the given DC. check_dc() calculates the required difficulty class so that a skill check has the given success/failure probability. See below for more details.

Usage

check_dc(roll, p, success = TRUE)

check_prob(roll, dc, success = TRUE)

Arguments

roll

A roll expression (e.g., 2 * d6 + 5) or a data frame returned by r().

p

The probability of success/failure of the check (or attack).

success

Whether to aim for success (the default) or for failure on the check (or attack).

dc

The difficulty class to beat for a skill check (or the armor class to beat for an attack).

Value

A numeric scalar.

Details

These functions hide the complexities of the roll family so users unfamiliar with R's d/p/q/r notation can get quickly up and running with the package. Since attacks and checks work in the same way (i.e., success means rolling a value higher than or equal to a certain threshold), there are no attack_*() functions.

For more details on roll expressions, see r() and the Dice S4 class.

See Also

roll, r(), Dice.

Examples

Run this code
# NOT RUN {
# Probability of d20 + 8 passing a DC 15 skill check
check_prob(d20 + 8, 15)

# Probability of d20 + 8 missing an AC 15 attack
check_prob(d20 + 8, 15, success = FALSE)
# }

Run the code above in your browser using DataLab