gsy <-
function
() {
s <-
c
(
"Diamond"
,
"Seven"
,
"3Bars"
,
"2Bars"
,
"1Bar"
,
"Cherry"
,
"Zero"
)
sample
(s,size=3,replace=
TRUE
,prob=
c
(0.02,0.04,0.05,0.12,0.15,0.04,0.5))
}
gs<-
function
(s) {
s1<- s[1] == s[2] && s[2] == s[3]
b <- s %
in
%
c
(
"1Bar"
,
"2Bars"
,
"3bars"
)
if
(s1) {
cash <-
c
(
"Diamond"
=1000,
"7"
=800,
"3Bars"
=600,
"2Bars"
=400,
"1Bar"
=250,
"Cherry"
=100,
"Zero"
=0)
cash_p <-
unname
(cash[s[1]])
}
else
if
(
all
(b)) {
cash_p <- 5
}
else
{
cherry1 <-
sum
(s ==
"Cherry"
)
cash_p <-
c
(0,2,5)[cherry1+1]
}
d1 <-
sum
(s ==
"Diamond"
)
cash_p * 2 ^ d1
}
run <-
function
() {
s <-
gsy
()
print
(s)
gs
(s)
}
run
()