-
-
Save boboppie/5333043 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
## Simulate Grime Dice ## | |
red<-c(4,4,4,4,4,9) | |
blue<-c(2,2,2,7,7,7) | |
olive<-c(0,5,5,5,5,5) | |
yellow<-c(3,3,3,3,8,8) | |
magenta<-c(1,1,6,6,6,6) | |
## Play n match-ups between d1 and d2 | |
## Return the proportion of d1 victories | |
roll_dice<-function(d1,d2,n=1) | |
{ | |
d1rolls<-sample(d1,n,replace=T) | |
d2rolls<-sample(d2,n,replace=T) | |
return(mean(d1rolls > d2rolls)) | |
} | |
# Single Roll | |
roll_dice(red,blue) | |
# Average wins | |
roll_dice(red,blue,n=1000000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment