Created
May 19, 2019 02:48
-
-
Save DarwinAwardWinner/03393c59461db70028f9f47f5a5c150b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(tidyr) | |
d6 <- 1:6 | |
# We'll call the 3 dice X, Y, and D (D is the dragon die) | |
all_rolls <- expand.grid(X=d6, Y=d6, D=d6) %>% | |
mutate( | |
## Sum of all 3 dice; determines if you hit | |
sum = X + Y + D, | |
## TRUE if this roll has doubles in it | |
double = X == Y | X == D | Y == D, | |
## Number of stunt points for this roll (0 if no doubles) | |
SP = double * D) | |
## Compare every roll against every to-hit value, and set the stunt | |
## points to zero for all misses | |
all_results <- all_rolls %>% | |
crossing(data.frame(to_hit = 3:18)) %>% | |
mutate(hit = sum >= to_hit, | |
SP=SP * hit) | |
attack_summary <- all_results %>% | |
group_by(to_hit) %>% | |
summarize(Mean_SP = mean(SP)) | |
print(attack_summary) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment