A slot machine simulator in R. Based on the example outlined in Hands on in R Programming. The default configuration seems to have multiple plays (`n>1`) lead to being bankrupt. However it appears that setting the `betsize` larger leads to more profitable returns when using the default probabilities.

play(
  n = 1,
  betsize = 1,
  cash = 10,
  prob = c(0.03, 0.03, 0.06, 0.1, 0.25, 0.01, 0.52)
)

Arguments

n

number of plays

betsize

default is 1.

cash

amount of starting cash

prob

probabilities for getting diamonds (DD), 7s, bars (B,BB, BBB for single, double and triples),Cherries (C) and Zeros (0). Change the probabilities to change the odds of winning!

Examples

library(rslots)
res<- play(n=10, cash=100)
#> 0 BB 0 
#> $0 Won !
#> Balance: $99
#> 0 0 0 
#> $0 Won !
#> Balance: $98
#> 0 BB 0 
#> $0 Won !
#> Balance: $97
#> B B 0 
#> $0 Won !
#> Balance: $96
#> 0 0 0 
#> $0 Won !
#> Balance: $95
#> B 0 BB 
#> $0 Won !
#> Balance: $94
#> 0 0 0 
#> $0 Won !
#> Balance: $93
#> 7 0 0 
#> $0 Won !
#> Balance: $92
#> BB B BBB 
#> $5 Won !
#> Balance: $96
#> B 0 0 
#> $0 Won !
#> Balance: $95
res
#> [1] 95