I am trying to program a machine that has 3 independent "reels", that are "rolled", and stops on 3 random icons The base machine is a basic slot with e.g. 100 possible combinations. I could now calculate a probability table to find that the base machine has a Return to Player (RTP)
However, the machine can also enter a bonus state. e.g. 6/100 times it enters a bonus game for 15 rolls.
Pseudo code for the algorithm looks a bit like this:
For 15 spins:
-- every time three bonus icons are rolled
----- Payments are raised: 2x then 5x then 15x
I can program this, but I want to know how to calculate the payout, such that I don't have to find a suitable and balanced payout by trial and error.
My first intuition would be:
p(2x) = calculate the probability of getting into a bonus game and then getting to the 2x bonus = 3/100
p(5x) = calculate the probability of getting into a bonus game and then getting to the 5x bonus = 2/100
p(15x) = calculate the probability of getting into a bonus game and then getting the 15x bonus = 1/100
and then, based on this answer , summing the probabilities like this
$$\frac{((94/100) * payoffBase) + ((3/100) * payoff2x) + ((2/100) * payoff5x) + ((1/100) * payoff15x)}{100}$$
(Note that the numbers are examples.)
I feel like i'm definately missing something, especially since the bonus game only lasts for 15 spins, which I don't believe I'm taking into account.
Hope you can help!
$E_1=pr$ is the expectation value of the payoff in regular game. Here $r$ is the base payoff in a single regular game and $p$ the probability of winning in a single regular game. Let $E_b$ be the expectation value of the payoff in a 15-rolls bonus game, and $b$ be the probability of entering a bonus game. Then the expectation value of the payoff is $bE_b+(1-b)E_1$.
[We assume for simplicity that all bonus games will be finished; if otherwise players may leave the machine earlier, the statistics becomes more complicated.]
The expectation value for the payoff in the bonus game depends on how many of the 15 rolls are wins. Let $w$ be the number of wins in single regular games in a bonus game, $0\le w \le 15$. The payoffs of $R(w)$ then are (note I'm trying to nail down the fuzzy description, in particular the 3rd win already pays off with $2r$, the 6th win already with $5r$, i.e., raises of pay-offs are AT multiples of 3 wins, not AFTER... and pay-offs are instant/not revocable.) \begin{multline} R(0)=0r\\ R(1)=1r\\ R(2)=(1+1)r=2r\\ R(3)=(1+1+2)r=4r\\ R(4)=(1+1+2+2)r=6r\\ R(5)=(1+1+2+2+2)r=8r\\ R(6)=(1+1+2+2+2+5)r=13r\\ R(7)=(1+1+2+2+2+5+5)r=18r\\ \end{multline} and so on. The number of ways of distributing the $w$ wins over 15 is $\binom{15}{w}$. The probility of any particular sequence of $w$ wins is $p^w(1-p)^{15-w}$, so the probability of $w$ wins in the bonus game without regard of order is $\binom{15}{w}p^w(1-p)^{15-w}$. The payoff with $w$ wins is $\binom{15}{w}p^w(1-p)^{15-w}R(w)$. The expectation value of the payoff in a bonus game is $E_b=\sum_{w=0}^{15} \binom{15}{w}p^w(1-p)^{15-w}R(w)$, which concludes the maths of the expected pay-off.
Maple implementation:
This gives a payoff of $1.1516r$ if $p=0.4$ and $b=0.05$, for example.