# Slots Machine Matching feature

I'm designing a slot machine.

I need to find the number of combinations that two matching icons will appear side-by-side in a 3X5 window (3 rows, 5 reels (columns))

A match gives the user some payout.

Having the following assumptions: Icons: H1, H2, X (all the rest). Matching Icons: should meet on the same row (side by side) (wild doesn't count here)

Window is as follows:

|   |   |   |   |   |
---------------------
|   |   |   |   |   |
---------------------
|   |   |   |   |   |


I have listed all possible options, and now I would like to get the exact number of combinations per each option.

Example of what I need:

The number of possibilities for this kind of scenario (1 of 72 possible ones):

| H1| H2| X | X | X |
---------------------
| X | X | X | X | X |
---------------------
| X | X | X | X | X |


Number of H1 icons on reels 1-5: R1_H1, R2_H1, R3_H1, R4_H1, R5_H1

Number of H2 icons on reels 1-5: R1_H2, R2_H2, R3_H2, R4_H2, R5_H2

Number of all icons on reels 1-5: RL1, RL2, RL3, RL4, RL5 (respectively)

Some more examples:

| H1| H2| X | X | X |
---------------------
| X | X | X | X | X |
---------------------
| X | X | X | H1| H2|

| H1| H2| H2| H1| X |
---------------------
| X | X | X | X | X |
---------------------
| X | X | X | X | X |


And so on.. the only limitation I put is that H1 and H2 icons on the same reel have distance between them so I won't have kind of the following scenario:

| H1| H2| X | X | X |
---------------------
| X | X | X | X | X |
---------------------
| X | H1| H2| X | X |

• I aren't quite understanding your description of the multiple scenarios, could you clarify a bit? Perhaps a second example would help. – Dave Aug 6 '14 at 11:21

First you need the probability they'll be on the same line at all.

Then, go through each possible position on a line for H1, counting the number of possible H2 positions that pay out, and those that don't. The probability is payouts/(payouts + non-payouts).

Multiply the two probabilities and you'll have your answers.

There are more mathematically elegant ways to do this, or you could write a small program to brute force it, but for small numbers like this it's not really necessary.

• Thanks for your reply. Yet, I do look for the very elegant mathematical way to calculate this; cause the scenario I have posted above is just one of 72 all possible scenarios, and I prefer to have robust way to calculate this. – YevgenyM Aug 6 '14 at 10:56
• Write a program to brute-force it, then. Much else and you're over-engineering. – Dave Aug 6 '14 at 11:04
• Kind of considering the Brute-Force method now; possibly make it tree structure and then just scan it and count all possibilities for each scenario. – YevgenyM Aug 6 '14 at 11:33
• Sounds like a good plan. – Dave Aug 6 '14 at 11:50