Assume that you are playing craps with dice that are loaded in the following way: faces two, three, four, and five all come up with the same probability (1/6) + r. Faces one and six come up with probability (1/6) - 2r, with 0 < r < .02. Write a computer program to and the probability of winning at craps with these dice, and using your program and which values of r make craps a favorable game for the player with these dice.

Loaded craps function where r is the load

score = 0
roll_1 = 0
roll_2 = 0


craps_loaded <- function(r,point=0,reroll=0){

#Create random numbers from 0 to 1
rand = runif(1)
rand2 = runif(1)

#Assign ranges to dice roll with loads
if(rand < 1/6-2*r) (roll_1 = 1)
if(rand > 1/6-2*r & rand < 2/6-r) (roll_1 = 2)
if(rand > 2/6-r & rand < 3/6) (roll_1 = 3)
if(rand > 3/6 & rand < 4/6+r) (roll_1 = 4)
if(rand > (4/6+r) & rand < 5/6+2*r) (roll_1 = 5)
if(rand > (5/6+2*r) & rand < 6/6) (roll_1 = 6)

if(rand2 < 1/6-2*r)( roll_2 = 1)
if(rand2 > 1/6-2*r & rand2 < 2/6-r) (roll_2 = 2)
if(rand2 > 2/6-r & rand2 < 3/6) (roll_2 = 3)
if(rand2 > 3/6 & rand2 < 4/6+r) (roll_2 = 4)
if(rand2 > 4/6+r & rand2 < 5/6+2*r) (roll_2 = 5)
if(rand2 > 5/6+2*r & rand2 < 6/6) (roll_2 = 6)

roll = roll_1+roll_2

#Win if roll matches point
if(point == roll){
  return(1)
}

#Point Loss
if(roll == 7 & point != 0){
  return(0)
}

#Natural Loss

if((roll == 2 | roll==3 | roll == 12) & point == 0) {
  
  return(0)
  
}
  
#Natural Win
 
if((roll == 7 | roll == 11) & point == 0){
  return(1)
}

if(point != 0) {
  craps_loaded(r,point)
}else

(craps_loaded(r,roll))

}

Trials at r = 0 to r = .02

score = 0
set.seed(12332)
for(i in 1:10000){
  score = craps_loaded(0) + score
}
print(paste0("win % where r = 0 is ",(score/10000)))
## [1] "win % where r = 0 is 0.494"
score = 0
for(i in 1:10000){
  score = craps_loaded(.01) + score
}
print(paste0("win % where r = .01 is ",(score/10000)))
## [1] "win % where r = .01 is 0.4983"
score = 0
for(i in 1:10000){
  score = craps_loaded(0.015) + score
}
print(paste0("win % where r = .015 is ",(score/10000)))
## [1] "win % where r = .015 is 0.5049"
score = 0
for(i in 1:10000){
  score = craps_loaded(0.02) + score
}
print(paste0("win % where r = .02 is ",(score/10000)))
## [1] "win % where r = .02 is 0.5128"

Based on simulations of 10000, craps becomes increasingly winnable as r increases and becomes favorable where r is a little more than .01.