set.seed(20230908)
Death Saving Throw Success and Failure
In Dungeons and Dragons, a character who loses all of their hit points is knocked unconscious. After that, they roll dice to see if they die permanently or if they stabilize. Each turn, they roll a 20-sided die (a d20). A 10 or higher is a success, and a 9 or lower is a failure. Three successes stabilizes you, and three failures kills you permanently. The probability of success in any individual roll is 55%, but what is the probability of success on the whole series of rolls? To answer this, I’ll do a quick simulation.
Because we’re dealing with random numbers, I will set.seed()
to ensure replicability.
For a single trial:
<- 0
failures <- 0
successes while (failures < 3 && successes < 3) {
<- sample(1:20, 1)
roll print(paste("Roll:", roll))
if (roll < 10) {
<- failures + 1
failures else {
} <- successes + 1
successes
}print(paste("Successes:", successes))
print(paste("Failures:", failures))
}
[1] "Roll: 18"
[1] "Successes: 1"
[1] "Failures: 0"
[1] "Roll: 11"
[1] "Successes: 2"
[1] "Failures: 0"
[1] "Roll: 20"
[1] "Successes: 3"
[1] "Failures: 0"
Brilliant, I’m alive!
But now we want to repeat that many, many times to calculate the probability of success. I’m going to populate a vector called outcomes
with whether each trial resulted in a success – TRUE
means three successful saves, FALSE
means three failed saves.
<- 1e6
n
<- replicate(n, {
outcomes <- 0
failures <- 0
successes while (failures < 3 && successes < 3) {
<- sample(1:20, 1)
roll if (roll < 10) {
<- failures + 1
failures else {
} <- successes + 1
successes
}
}== 3
successes
})
mean(outcomes)
[1] 0.592789
After one million repetitions, it looks like the probability of success is about 59%. Better than 50-50, but still…not great when you’re talking life and death.