# Calculate slot machine game multiplier

I'm developing a slot machine game with 5 slots, each slot has 6 options (pear, lemon, ..., etc.).

Each spin, 5 random values get generated, one for each slot, making the slots spin to the option bound to their random number. When 3 or more consecutive numbers get generated in a spin eg.: (12444 or 42223 or 11111) the player "wins" the spin.

The won amount should be calculated depending on the number of consecutive equal numbers in a won spin, the amount the player bet that spin, and the value of the consecutive numbers (1 should be worth less than 6).

See included image for an example win chart, in short the question would be: how can I calculate the multiplier for each option (eg. 25* 5* in the image) which would result in a +-48% chance of making a profit on the machine?

There aren't exactly nice formulas for these things; you just have to use inclusion/exclusion.

If all six symbols are equally likely, the chance of getting all five the same is the chance that the left symbol matches each of the subsequent ones,

$$(1/6)^4 = 1/1296$$.

The chance of getting exactly four in a row is the chance of getting the first four in a row, plus the chance of getting the last four in a row, minus twice the chance of getting all five in a row (since this is counted twice, once in each case). So that's

$$2(1/6)^3 - 2(1/6)^4 = 5/648$$

The chance of getting three in a row can be calculated similarly with an uglier expression.

Then you just pick numbers to make the probability come out to what you want; there are lots of potential solutions.

That said, you probably want to optimize the expected value rather than the chance of winning, assuming the payout is higher for four in a row than for three in a row.