Stickin’ It!

Over the past few years, we have become acquainted with slot games featuring variations on the stick’n’respin theme. In one of the most popular of those, a 3×5 machine, the wild symbol is present on Reels 2-4. When it lands in the window, it expands vertically to the entire visible part of the reel. The paylines are then evaluated (both left-to-right and right-to-left!) and the wild reel sticks during a free respin. If during a respin an additional wild symbol appears, it too will expand to the whole reel before line evaluation, and stick for yet another free respin. The process continues until no additional wild symbols appear. Thus, a player can get up to 4 spins with an increasing number of reels covered by wild symbols, all by staking and pressing the PLAY button only once.

As a continuation of the previous post, it is briefly explained below how this can be solved by means of Markov chains. Each spin in a “stick’n’respin cycle” is started with each of Reel 2, Reel 3 and Reel 4 being either wild or not. We will therefore work with 9 states numbered from 0 to 8, where 0-7 represent spinning with one of the possible wild distributions (think binary!) and 8 represents “no more spins”. Knowing the probabilities that a wild symbol appears on a specific reel, we readily get the transition probabilities between the states. Always performing the initial spin in State 0, it turns out that we will surely end up in State 8 no later than prior to the 5th consecutive spin (which is thus not executed).

If we consider a 3-bit binary number, where the least significant bit represents Reel 2, then we get a natural enumeration of the states 0-7. If the “wild probabilities” are, say, 0.02, 0.05 and 0.03, for reels 2, 3 and 4, respectively, and we repeatedly multiply the resulting transition matrix from the left by an initial vector with probability 1 for State 0 and probabilities 0 for all other states, we end up at the following table.

Expanding wild stick'n'respin probabilities

Expanding wild stick’n’respin probabilities

It is then a matter of calculating the conditional averages given that some of Reels 2-4 are wild which, to a large extent, is a matter of copy and paste (once we have the average for State 0). The nth column in the above table contains the probabilities that the nth spin is executed in State k, where k=8 means that the spin is not executed at all.

Another popular concept involving sticky wilds is to let all wild symbols popping up during a freespin session stick in their positions for the remainder of the freespins, thereby overriding any symbol that appears underneath. Assuming a possibly random but fixed number of freespins, we can solve this in a similar manner. Note that we may consider one payline at a time, and expand the average return linearly to all lines. If the wild symbol is present on all five reels, we have to deal with 32 states and need the conditional average for each of them. The corresponding probability table dictates how often the nth freespin is played with wild configuration k. These are then multiplied with the corresponding conditional averages and the sum of the products is the average total session win. Watch out if retriggers are possible!

A third variation on the same theme is to let the triggering scatter symbols turn into wilds and remain in their positions during an entire freespin session. It is standard that three or more scatter symbols are required (anywhere in the symbol window) in order to start the freespins. There are a number of differences compared to the previous concept, the most important ones being that we do not start at State 0, and different paylines are in general affected differently by the wild symbols. For simplicity, we assume that no additional wild symbols can appear during the freespins. Suppose that the game has 20 paylines. Then, given a triggering scatter/sticky wild combination, some of the paylines may not be affected at all while others have one or more wild symbols given.

Paylines are affected differently

Paylines are affected differently

Thus, in general, for each possible triggering combination we get one “line count” for each of the 32 possible wild configurations, adding up to 20. Again, we need the conditional averages for all possible wild configurations. Once those are in place, we weigh them with the line counts mentioned above to get the average total win per spin.

In order to complicate things, the latter two can be combined. It gets a little messier if we allow retriggers, since then we don’t know in advance how many freespins will be played. Also, we need to define whether or not a scatter symbol shall count should it appear underneath a sticky wild. All in all, however, it is usually possible to solve the game analytically with a bit of caution.

Linear Algebra, Cats and Dogs, and Markov Unchained

How can linear algebra be useful when designing a slot machine, other than indirectly through affine transformations when doing animations?

When creating the mathematical model of a slot machine, most calculations are rather straightforward. Sometimes complex, yet usually overviewable. However, in some situations, a mathematical trick or two may come in handy.

Suppose, for instance, that the slot machine features a pick’n’click bonus game in which the player gets to pick a number of boxes to reveal her wins. The bonus game is triggered when three or more DOG symbols appear in the slot machine window in one spin, and the number of picks is determined by how many CAT symbols that have been collected prior to entering the bonus game: 0 or 1 cat – one pick, 2 or 3 cats – two picks, 4 or more cats – three picks. It is then essential to find, not the average number of CAT symbols at the time when the bonus game is triggered, but the probabilities to enter the bonus game with 0 or 1, 2 or 3, at least 4 collected CAT symbols.

Or, we could consider the case where three or more BONUS symbols appearing in the slot machine window triggers the free game feature, where the player is given 10 free games with multiplier 2x. Whenever a PEARL symbol appears in the middle position of the middle reel, the multiplier increases by 1x for subsequent spins, up to at most 5x. We would then need to find the probabilities for spins 1, 2, …, 10 to be played with multipliers 2x, 3x, 4x and 5x, respectively.

It is, of course, possible to run simulations to estimate the sought probabilities. This is, however, not only personally unsatisfactory, but more importantly, some legislations do require that we calculate the exact parameters related to the rtp of the game.

One way of doing this is to set up a Markov chain or Markov process. Briefly, this is a system made up of states between which we transfer with certain probabilities from one observation point or period to the next. These transition probabilities depend only on the current state; they lack memory, in the sense that they are not affected by what has happened before the current state.

The second example above, translated into the language of Markov chains, has four states and ten observation points, the states being “Multiplier m”, where m=2,3,4,5 and the observation points being the ten free game rounds.

Collecting the transition probabilities in a matrix, we can use matrix multiplication to find the probability of being in a certain state after any number of observation points (this is where the linear algebra plays its role!). If the probability of getting a PEARL symbol at the middle position of the middle reel is, say, 1/8, then each column of the following matrix contains the probabilities of transferring from one state to each of the other.

b05matrix01

First spin is always played with multiplier 2, so the corresponding initial state vector looks like this.

b05matrix02

Performing matrix multiplication repeatedly, we end up with the following table, showing the probabilities for playing the nth spin with multiplier m.

 b05table01

It is left as an exercise to make the necessary modifications for the CATS and DOGS example above.