Formal Modelling and Analysis of Slot Machines
Abstract
Slot machines can have fairly complex behaviour. Determining the RTP (return to player) can be involved, especially when a player has an influence on the course of the game. In this paper we model the behaviour of slot machines using probabilistic process specifications where the intervention of players is modelled using non-determinism. The RTP is formulated as a quantitative modal formula which can be evaluated fully automatically on the behavioural specifications of these slot machines. We apply the method on an actual slot machine provided by the company Errèl Industries B.V. The most useful contribution of this paper is that we show how to describe the behaviour of slot machines both concisely and unequivocally. Using quantitative modal logics there is an extra bonus, as we can quite easily provide valuable insights by a.o. computing the exact RTP and obtaining the optimal player strategies.
1 Introduction
Gambling machines such as slot machines combine random behaviour, stemming from spinning of reels, with player input, when allowing to hold specific reels. A major metric for such machines is the payout, also called the ‘Return To Player’ (RTP). The RTP is the average part of the inserted money which is returned to the player in each round. A lower bound on the RTP is commonly required by law or regulation and differs per country. For example, in the Netherlands slot machines must have an average payout of at least 60% and do not allow players to loose more than 40 euros per hour ([29, Articles 12f and 12g]; see also [21]). It is of course also undesirable for the owners of such machines when the average payout exceeds what is inserted, i.e., the RTP should be less than 100%. Determining the RTP is therefore crucial when designing slot machines. However, as these machines can be quite complex, it can be difficult to assess the RTP with traditional mathematical methods. Monte Carlo simulation can be quite effective in such situation, but it remains a probabilistic simulation technique and can require a large number of simulation runs.
In this paper, we model the slot machines using probabilistic process specifications and formulate the property of interest, such as the RTP, using quantitative modal formulas [13]. By using process descriptions quite complex behaviour can be concisely described. These models can be analysed fully automatically using model checking of modal formulas and this yields precise answers. For example, we can check whether the expected payout lies within the required bounds. In contrast to traditional mathematical methods, model checking is performed fully automatically on the model specification and requires no user intervention. In contrast to simulation-based techniques, model checking exhaustively explores all possible behaviour and therefore also considers rare events which only occur with marginal probability.
Process specifications
Process algebras are very natural formalisms to describe and study the behaviour of complex systems. These formalisms find their origin in the work of Milner [27]. Systems can perform actions, such as displaying information or receiving an indication that a button has been pressed. Abstractly, actions are denoted as and , and more informatively as or . A process algebra expression specifies all possible sequences in which such actions can occur, which we call the behaviour. In this paper we use the process algebraic specification language mCRL2 [13].
Modal formulas allow to formulate a wide range of properties for the behaviour of the modelled system. A typical example is that ‘whenever action happens, action will inevitably take place’. We use the modal mu-calculus with data, which is very expressive, in particular more expressive than other modal logics [7]. Using model checking techniques, we check whether the given modal formula is satisfied on the given process specification. In other words, we verify whether the modelled system ensures the desired behaviour. Tools and theories that support process descriptions and allow to verify properties in the modal mu-calculus are CADP [9] and mCRL2 [12].
Probabilistic process specifications
The process algebraic descriptions have been extended to incorporate probabilities. Using this it can for instance be expressed that ‘after an action with probability of 25% an action will happen, and with probability 75% both actions and are possible’. This allows to specify and investigate behaviour of systems that rely on probabilities.
Quantitative modal logics yield numerical values instead of the booleans true and false, when evaluated on behaviour. Using these logics various properties can be establish such as the probability that a particular action will happen, or the expected number of times that action will happen. There are various tools that support probabilistic process behaviour and allow to verify properties such as Prism [24], Storm [18] and Modest [16]. We employ the recent quantitative extension of the modal mu-calculus as outlined in [15] which has been implemented in the mCRL2 toolset [12].
Modeling slot machines
We start out by modelling a number of simple slot machines to illustrate the approach. Subsequently, we apply the techniques to the TopSpinner slot machine produced by Errèl Industries B.V. [8]. This machine was produced in 2001 and is not in commercial use anymore. We model the TopSpinner in mCRL2 and analyse its behaviour via quantitative model checking.
It turns out that modelling slot machines is very well possible, once one masters the technique of process algebraic specification and quantitative model checking. Two of the three non-trivial games of the TopSpinner neatly produce a return to player of 94% and our final model of the third game has a payout of 83%.
However, using the available documentation it was hardly possible to figure out how this slot machine operated precisely. It required a number of clarification rounds, and even the use of a simulator of the actual slot machine, to be able to provide precise formal descriptions. We initially started with this project to investigate the effectiveness of quantitative modal logic in the setting of slot machines, and that turned out to work fine. But we came to the conclusion that the formal modelling of the behaviour of slot machines per se is a much larger contribution. Formal modelling is perfectly suited to denote what slot machines are supposed to do, which besides as a basis for analysis, is an excellent way to communicate this behaviour with for instance gambling authorities.
Related work
There is remarkable little literature on slot machines, given their relative popularity and nice probabilistic nature. Very simple slot machines have been used as illustration, see e.g., [6, 26]. The mathematics of slot machines has been investigated in [4]. Analysis of slot machines via Monte Carlo simulation was considered in [5]. One goal of slot machine analysis is optimizing the RTP such that it falls within the desired bounds. Several approaches exist for this optimization problem, based on genetic and evolutionary algorithms [2, 3, 22] or using Variable Neighborhood Search [20].
Outline
Acknowledgements.
We are thankful to Eric van de Pas from Eurocoin gaming for his kind patience in answering all our questions about slot machines.
2 The specification formalisms
We describe the behaviour of systems in mCRL2, a (probabilistic) process algebraic behavioural specification language [13]. Quantitative modal logic is used to express probabilistic properties of this behaviour, such as the expected payout of a slot machine [15]. In the next two sections we explain the necessary ingredients of both formalisms.
2.1 Probabilistic process expressions
Probabilistic process specifications consist of two parts, namely data types and behaviour.
Data types
All normal data types can be used, such as booleans (), natural numbers (), integers (), real numbers (), and lists ( where is an arbitrary type). Lists are typically denoted within square brackets, such as . The -th element of a list is denoted as , where the first element of the list is .
Enumerated types are typically declared using the struct keyword, as follows:
where is now the data type containing the three elements , and .
Auxiliary functions and constants are declared using the map keyword, followed by defining equations, employing the keyword eqn and the keyword var to declare the variables used in the equations. An example to determine whether three symbols are all equal is the following where represents equality on data elements.
The equations are evaluated as term rewriting rules from left to right. They can be preceded by a condition, in which case the rewrite rule is only applied if the condition rewrites to true. Within equations we often use the ternary operator to represent the value if the boolean is true and if is equal to false.
The data types are far more versatile, also allowing for instance function types, sets, bags and recursive types, but as they are not required in the rest of this paper, we do not explain those.
Behaviour
Behaviour is described in the process algebraic style. The essential element in process algebra is the action, typically denoted in an abstract way by , , . They represent some atomically occurring event. If the event has some meaning, then more informative action names can be used such as or . Actions can have parameters, which are then denoted after the action within brackets. A typically example is which typically could indicate the atomic activity of paying out credits, or with three booleans that indicate which of the three hold buttons are pressed. Actions are declared using the keyword act.
The operator ‘’ is used to sequentially compose two behaviours. E.g., represents that first the action takes place, followed by the action . The operator represents non-deterministic choice between two behaviours. For instance means that it is either possible to do or do where the first action, or , that is done determines the choice. There is one process, called deadlock, written as , which cannot perform any action. It typically satisfies the equation for any process .
The operator ‘’ can also be written using the sum operator . Consider a process , which is a process depending on a boolean . Suppose we want to express that either the behaviour or can be done. This is expressed by , but using the the sum operator it can be written as . The sum operator can be used with any data type, and with one or multiple variables.
Using the conditional process operator , it is possible to let data influence the course of a process. If is true the behaviour of is executed, and if is false the behaviour of takes place. Note that the conditionals on data and processes have different notation, but they have essentially the same effect. When omitting the else-part, i.e., this process executes when is true, and is equal to deadlock otherwise.
Using process equations, iterative or recursive behaviour can be denoted. A simple example is the behaviour of the process which can perform the action followed by the behaviour of . So, can do an infinite sequence of actions . The process starts with the behaviour indicated by the keyword init.
The keyword proc is used to indicate the process equation. At the left side of the equals sign a single process variable occurs of which the behaviour occurs at the right hand side.
Such behaviour is interpreted as a labelled transition system, also called a state machine. It has a set of states and transitions labelled with actions indicating how the behaviour goes from state to state. The state machine for the process is drawn at the right of . It consists of one state and a transition labelled with the action going from and to this state indicating that the action can be done infinitely often in sequence.
Process equations can also have zero or more parameters. As an illustration we write the behaviour of a counter that can count up and down, but not count below zero. The counter initially starts with the value .
Note that the operator is used here both as the addition on integers and as the non-deterministic choice between processes. Also observe that if the action cannot be done, but the action is still possible. The labelled transition system belonging to this process is infinite and is partly drawn at the right of the process specification.
Probabilistic behaviour is indicated by which expresses that the behaviour is executed with a value for the variable which is chosen according to the distribution . The distribution must sum up to one over all elements of the distribution. As a concrete example we express that one of the symbols , and is displayed, each with probability using the following process specification. In this case we only allow to gamble once, and we indicate that by putting after the display action.
The transition system drawn at the right is a probabilistic transition system. In this case, with probability one of the states at the mid level are selected, from which actions can be done. This two layer behaviour, first probabilities and then actions, can be repeated to indicate repeated probabilistic choices. When there is only one single probabilistic transition with probability in a state, then it is generally omitted and the action transitions are drawn immediately in that state.
Besides probabilistic behaviour it is also possible to model non-deterministic behaviour, which is behaviour that is fully unpredictable. For instance, when a slot machine has hold buttons to fix a particular symbol on the screen it is unpredictable which buttons a player will press. Note that this pressing behaviour is not random, as the player can or cannot have a particular strategy. Using the ‘’ or operators such non-determinism can be expressed. We extend the previous example with a hold button where means that the hold button is pressed, and means the symbol is not fixed and can be randomly set again. Note that the equation for models the game where the symbol needs to be randomly chosen, and models the game where the symbol is set to .
The language mCRL2 offers more ways of describing behaviour, in particular to describe parallel communicating components and time. We refer to [13] for the details.
2.2 Quantitative modal logic
Modal logics are developed to state and evaluate properties about behaviour. There are various modal logics, but we use Hennessy-Milner logic [17] extended with fixed point operators and data [13], called the modal -calculus, as this is the most expressive modal logic available [7]. In this logic each formula is evaluated on a state of a transition system and interpreted as true or false.
In [10, 11, 15] this logic is extended and interpreted on , i.e., each formula yields a real number including . Such a formula can be a real number, , interpreted as , , interpreted as . There are operators , , where is interpreted as the minimum and represents maximum. It is also possible to multiply a formula with a positive constant as in . A valid formula is , which on any transition system is interpreted as .
Using the diamond modality and the box modality the logic is connected to a probabilistic transition system. These modalities stem from [17]. The evaluation of a formula in a state with probabilistic transitions is the value obtained by evaluating the formula in the target states multiplied with the probability of the transition.
The evaluation of the diamond modality in a state with outgoing action transitions is the maximum of the evaluation of in all states reachable via an action . If there are no outgoing -transitions, the interpretation is . For instance, the evaluation of in the transition system of the process is , because the probability to perform action is . Using the explicit values and it evaluates to if the action is possible in a state, and to if not. Using the probabilities, this value contributes to the result. Note that the formula would evaluate to because the formula evaluates to in any state without outgoing transition . Such states occur at the left and the right. These -ies dominate the outcome which is also .
The box modality does the same as the diamond modality, except that it takes the minimum of the evaluation of over all -transitions that it can do. If there are no -transitions the box modality evaluates to infinity. Note that in states with exactly one outgoing transition labelled with action , the diamond modality and evaluate to exactly the same value.
Instead of an action, it is also possible to put a regular expression between the modality operator, such as and . The represents any action and stands for any finite sequence of actions. For instance is the probability that the action is reachable.
Using the infimum and supremum operators, and , respectively, it is possible to minimise or maximise the value of a formula over the elements of a data domain. For instance, provides the maximal value of evaluating this formula with , and .
Using the minimal fixed point operator and maximal fixed point operator values for iterative behaviour can be obtained. Concretely, consider a minimal fixed point formula where can occur in . If this formula is evaluated in a state, it yields the smallest value such that equals with in set to . When the maximimum fixed point formula is used, it yields the largest such value . For instance, the formula is equal to if it is evaluated on a transition system that can perform an infinite sequence of actions as in the process . Otherwise, it evaluates to .
In fixed point operators, parameters can be used. For instance, the formula counts the maximal number of consecutive actions . It provides the smallest value , being at least , and at least one more for every consecutive action that can be done. If an infinite number of actions can be done, this formula yields .
3 Simple slot machines
We show how to make models of slot machines of increasing complexity. The behaviour of the slot machine is systematically described in the behavioural language of mCRL2. Assessment of winning probabilities and ‘return to player’ are obtained via modal formulas.
3.1 A one column slot machine
We start with a simple slot machine showing only one symbol selected out of a star, grapes and an orange with equal probability. When a star is shown the player wins one credit. In the other two cases he loses and it costs one credit. Directly after winning or losing, the player can play again, and this can be repeated indefinitely.
The probabilistic transition system for the one column slot machine is given below.
The probability to win a single game is given by the modal formula
The answer is .
We can replace by
(1) |
which also yields . It says that after an arbitrary action, is returned if is possible, and otherwise . These values are weighted with the probabilities in the distribution.
Replacing by changes the meaning. The formula now becomes
It gives the probability of reaching after an arbitrary sequence of actions. This essentially provides the probability that on the one column slot machine star will ultimately appear. This probability is of course as is confirmed by evaluating the formula.
The expected number of times one has to play to encounter a star is given by the formula
(2) |
This formula expresses that the expected number of rounds to encounter a star is equal to if the star is encountered directly, and it is plus the expected number of rounds if no star is observed in a round. We search for the minimum value of the fixed point that is at least zero. If zero is not added, the minimal solution is . The formula evaluates to meaning that one encounters a star after rounds on average.
The one column slot machine behaves exactly the same for every round. But suppose we would be interested in the average long run reward per round, this can be formulated by:
(3) |
We calculate this gain explicitly for of rounds. In the variable the cumulative gain for all rounds is recalled. If the number of rounds becomes equal to the maximal number of rounds, the average gain is returned. Otherwise, if the game is won, indicated by the modalities , the expected value with the gain incremented by is delivered, and if the game is lost, shown by , the expected value with the gain decremented by is the result. Note that the use of variables in fixed point operators allow for far more complex results to be derived on behaviour. As expected, evaluating this formula on the behaviour of the one column slot machine yields an average gain of . In Section 4.4 a variant of this formula is used where only one parameter in the fixed point variable is required.
3.2 A three column slot machine
A three column slot machine has three windows where stars, grapes and oranges can appear each with equal probability. A game is won if in all three windows the same symbol appears. Its behaviour is described using the following mCRL2 specification. Note the use of if-then-else, denoted by , which describes winning if the symbols are equal, and losing, otherwise.
We can essentially analyse this game with the same formulas as in the previous section. The probability to win the game once, given by formula (1) is . The formula (2) to indicate the expected number of steps to win must slightly be adapted, as winning now means seeing three similar symbols. It becomes:
(4) |
and yields the answer .
The average expected loss per game is given by the formula (3) and it yields .
3.3 A three column slot machine with hold buttons
Slot machines sometimes have hold buttons. After a game in which nothing was won, the player can press the hold buttons under each symbol, to fix these symbols for the next game. For a three column slot machine this is beneficial for the player, because when there are two equal symbols that are fixed, the probability of winning the next game increases to .
The behaviour of such as slot machine becomes more complicated. Not only the winning probability can differ for each game, but also there is non-deterministic behaviour as the player may or may not press the hold buttons.
The slot machine with hold buttons can be described as follows.
The behaviour is given by the process with parameters. The first three parameters , and indicate which of the hold buttons are pressed. The last three parameters represent the symbols shown on the screen. Initially, the hold buttons cannot be used, as indicated by ,,. In this case the initial symbols on the screen are not relevant, and they are arbitrarily set to , , . Note that after the action , the hold buttons are also disabled.
When playing, the symbols are set using the mapping where is a boolean and and are symbols. This mapping determines the probability to display symbol in a single column. If boolean is true, the hold button for this column is pressed and is equal to the pre-set symbol with probability . Otherwise, is equal to some concrete symbol with probability . Using the action it is indicated which symbols are shown on the screen.
Clearly, if all symbols are the same, the player wins one credit, indicated by the action . Otherwise, the player loses a credit shown by the action , after which the player can indicate which hold buttons should be pressed. Subsequently, the player can continue to play.
Using the formula (4) it is determined what the probability is to win the game in the first round, which is leading to an expected loss of credits in the first round. But on the one hand if the hold buttons are used well, the winning probability can be increased and the average loss can be restricted. On the other hand, if the hold buttons are used very badly, the loss is increased. To get insight in the effect of the hold buttons, we investigate three situation, namely first where the hold buttons are used perfectly, second where the hold buttons are used in the worst possible manner, and third where the hold buttons are used randomly. We summarize the results in Table 1.
Strategy | Winning probability | Expected loss |
---|---|---|
Best | 0.2591 | -0.4818 |
Worst | 0.0001 | -0.9998 |
Random | 0.0886 | -0.8227 |
Best strategy
The following formula corresponds to the maximal winning probabilities per round where the player uses the hold buttons in the best possible way. Again we use the constant to set the maximum number of rounds over which the average is calculated.
(5) |
The sequence matches an action followed by an action . Similarly, the sequence matches a , followed by , followed by an action . This action hold is non-deterministic, and by using the diamond modality we take the maximal winning probability over the various possible settings of the hold buttons. Setting to yields a winning probability of per round. This corresponds to an expected loss of credits per round.
Worst strategy
By replacing the last modality in in formula (5) by the minimal expected winning probability is obtained which corresponds to the situation where a player presses the hold buttons in the worst possible way. Evaluating this formula over rounds, yields a winning probability of . This corresponds to the situation where after the player lost a game, the player continuous to press all hold buttons. This causes a certain loss of the game in each round, explaining the success rate of close to and an expected loss of per round.
Random strategy
We may also be interested in the situation where a player plays ‘naturally’, in the sense that he does not play optimally nor perfectly badly. The question is how to model ‘natural’ behaviour. One way is to assume that the player randomly presses the hold buttons. The average winning probability for this situation is expressed in the following formula.
In the last line it is expressed using the sum operator that each pattern of pressing the hold buttons should be considered as appearing with probability . This formula then evaluates to an average winning probability of and an average loss per round of credits. Note that by taking a more elaborate formula for pressing the hold buttons, more delicate behaviour can be modelled, for instance by only allowing to press the buttons when equal symbols are shown.
4 Top Spinner from Errèl Industries B.V.
In Figure 1 a slot machine called the Top Spinner produced by Errèl Industries is depicted111A similar, online playable version is available at [28]. It has a playing window of three rows and four columns, four corresponding hold buttons and contains four games. Initially, the reel game is played of which the winning combinations are depicted at the bottom of the machine. The payout of the reel game is moved to the pots. Alternatively, the zero-one-game is used to transfer credits to one of the eight pots. This game is very simple and corresponds to the zero and one on the bottom part of the cabinet in the right upper corner. If a pot contains more than 5 or 10 credits, the five-play-line or ten-play-line game can also be played, respectively, although it is obligatory to play the zero-one game once before a play-line game can be played. If all pots contain more than 5 credits the reel and zero-one games are not available. The winning scheme of the two play-line games are depicted at the top of the machine. We describe all four games separately below, and analyse the three most complex ones.
4.1 The zero-one game
The zero-one game is used to transfer money to the pot and it must sometimes be played before the play-line games can be done. With probability of 99.9% a credit is successfully transferred, and otherwise it is lost. This game is so simple that we do not analyse it further.
4.2 The five-play-lines game
The five-play-line game requires five credits to play. It corresponds to the winning lines indicated with 1 to 5 at the upper part of the cabinet. Each winning line has length 3 and considers columns A–C. If one of the combinations at the top occurs at a winning line, then the corresponding amount is payed out. For instance, the combination star-star-star yields 200 credits, and three bells yield 40. If multiple winning lines show winning combinations, the payout is added up. The stars have a double role. A star in column one is also an orange, a star in column two doubles as a pear, a star in the third column is also a blueberry, and a star in the last column is also a bell. So, the combination star-orange-orange is also good for 40 credits, as are pear-star-pear and blueberry-blueberry-star. The combination bell-bell-star is not relevant for the five-play-line game, as the five winning lines only use the left three columns.
The game does not use the hold buttons, and in that sense is similar to the three column slot machine from Section 3.2, albeit more complex. The expected reward for each round is exactly the same, and therefore it suffices to analyse a single round of the game.
The behavioural model in mCRL2 is provided in Figures 2 and 3. In Figure 2 the basic data types are provided that are both used in the five-play-lines game and the ten-play-lines games. The sort contains the nine symbols that play a role. Each reel is modelled as a list of length 24. The reels are , , and , counted from left to right. So, is the left most reel, containing an orange, an orange, a star, etc.
The functions get the -th symbol from reel . As each reel has length 24, a symbol at position is put at the lowest line of the display of the slot machine with probability , provided . This is defined in the mapping .
The behaviour of the five-play-line game is specified in mCRL2 in Figure 3. It describes only a single run of this game, as only this is interesting. At the init it is stated that variables , and are chosen according to the distribution given above. Each is an index in reel smaller than 24, chosen with probability . Based on the values , , a reward is displayed, which is defined using the mappings and . The mapping encodes the winning lines and the mapping represents the price each winning line provides as indicated at the top of the slot machine.
We are interested in the expected return to player of this game, given by the following formula, which only looks at the payout of a single run. Recall that playing this game costs five credits.
This formula evaluates to . As a game costs 5 credits, the loss per credit is . Our analysis therefore yields a return to player of , which is close to the RTP of 95% reported on the website [28].
4.3 The ten-play-lines game
The ten-play-line game is very comparable to the five-play-line game. The differences are that playing it costs 10 credits, but in return the payout is now in accordance to the 10 play lines indicated at the top of the cabinet. The additional five play lines use columns B–D, and the overall payout is the sum of all winning sequences of three symbols over all 10 play lines.
The behaviour of this game is specified in Figure 4. We use a parameter in to indicate in which column the sequence , , starts. If is located in column 1 the winning combinations with a are different than when is located in column 2.
The formula for the expected average gain of this formula is the same as for the five-play-line game, except that each game now costs 10 credits;
Evaluating this formula yields which is twice the average expected loss for the five-play-lines game. This also yields a 94% return to player, exactly the same as for the five-play-lines game. Apparently, there are no extra winning combinations for the ten-play-lines game from which a player can benefit. This is in contrast to [28] which states a RTP of 97.50% for the ten-play-lines game.
4.4 The reel game
The reel game is played on four columns and a single line, where the hold buttons can be used. Playing this game costs one credit. The winning combinations are listed at the lower part of the cabinet. Essentially, a reward is awarded if the first 2, 3 or 4 symbols from left to right are the same. So, for instance, four stars yield 200, three stars at the left yield 100 and two left stars provide 8 credits. As with the play-lines games, stars have a double role, namely as orange in the first column, as pear in the second, as blueberry in the third and as bell in the last columns.
Interestingly, we had difficulties understanding how the hold buttons were supposed to be used. We think that it is useful to explicitly go through some variants we encountered, as it underlines the need for a formal description of the game when communicating the rules to for instance gambling authorities. We summarize the expected payout for the different variants in Table 2.
Variant | Max. expected gain | RTP | |
---|---|---|---|
mCRL2 | mCRL2 | website | |
Always allow hold | 1.5652 | 256.52% | — |
Hold with extra cost | 0.6916 | 169.16% | — |
Only hold one round | -0.1690 | 83.10% | 88.50% |
At a particular moment we got access to the playable version of the TopSpinner [28], which was helpful to increase understanding. However, the average payouts mentioned on the website differ somewhat from our results. There are various explanations for this difference of which one is that we still do not exactly capture the rules of the game, although we consider this unlikely.
Always allow hold buttons
In our initial model, we assume that the hold buttons can always be used, except at the start of the game and directly after a winning combination, as otherwise the winning combination could be fixed, and a player could repeat this winning combination indefinitely.
The data of this model is listed in Figure 5 and the process behaviour in Figure 6. In the process behaviour we use the glob keyword to declare ‘global variables’. The meaning of these variables is that they can be set to any value, without influencing the meaning of the specification. Tools instantiate these variables to appropriate values that allow to optimise the verification efforts.
The most interesting question that we like to ask is what the average maximal return to player is when the player plays the game optimally. The following formula provides this maximal expected gain per game when the player plays rounds:
(6) |
The variable in this formula has as value the maximal gain when games have been played. If the variable is equal to the gain is set to . Otherwise, a round of the game takes place, modelled by the action where the boolean is true when column is set to hold. The formula calculates the supremum over all hold settings. It obtains the points that are won, and changes the maximal gain by adding to the maximal gain. Note the use of . As the amount that is won is uniquely defined, this supremum only acts as a binder for the variable .
The results are unexpected and are provided in the graph in Figure 7 as the continuous blue line. On the -axis the number of iteratively played games are indicated and on the -axis the maximal average gain per game is depicted. When playing one game the average loss is credits, which is understandable as the player cannot influence the game with the hold buttons. When playing at most two games the minimal loss is per game. But when optimally playing four games there is already an average profit of credits. This increases to an average profit for the perfect player per game of more than credits if the game is played for more than 200 rounds.
Hold with extra cost
The question arises whether it is really possible to have an expected profit on this actual machine. After some discussion, the company suggested that when applying the hold buttons, an extra credit had to be paid. This is easily modelled by changing the last part of Formula (6) into . The results are depicted in Figure 7 as the middle purple dashed line. Clearly, the average gain is less, but in the long run the player can still obtain a gain of per game. It is unlikely that this is actually the case.
Only hold for one round
After more discussion, and especially, looking at the slot machine simulator [28], it appears that when the hold buttons are used in a certain round, they cannot be used in the next round.
We model this by replacing the following line in the model in Figure 6:
by
This expresses that if one of the hold button is pressed, the next round is played with all variables representing the hold buttons set to . Otherwise, if no hold button is pressed, the hold buttons in the next round can be set at will.
In the web simulator there is no additional fee for using the hold buttons, so we use Formula (6) without alteration. Evaluating Formula (6) yields rewards conforming to the lower, grey dotted line in Figure 7. On the long run, when playing optimally, a loss of per game is expected, i.e., a return to player of . This result is not in line with the stated RTP of on the website [28].
Validation
Comparing the RTP from our mCRL2 model with the RTPs stated on the website [28], we see discrepancies. This is similar to the five-play-lines and ten-play-lines game where the website claims RTPs of respectively and , whereas we find an RTP of for both games. In order to exclude mistakes from our side, we also modelled and analysed the games using the model checkers Storm [18] and Prism [24]. Both tools yield the same results as mCRL2.
Optimal strategies
An interesting question as a player is when and which buttons to hold in order to achieve the best RTP. For the reel game in which the buttons can only be held for one round, we can extract the player strategy leading to the optimal RTP of 83%. To this end, we use the Storm model checker [18] and export the optimal strategy which details for each possible reel outcome which buttons should be held. In order to achieve a small and human understandable strategy, we employ the tool dtControl [1] to create a decision tree from the obtained strategy.
Figure 8 depicts a part of the decision tree for the reels game in which a button can only be held for one round. A node of the form ‘fruit’ represents the check whether reels and show the same fruit symbol, ‘star’ checks whether both reels show the star symbol. The player strategy is given by ‘hold’ which represents that the player should hold the indicated columns.
The obtained strategy leads to some interesting insights. For instance, stars are higher valued than fruits. This can for instance be seen in the case where reels 1, 3 and 4 show the same fruit symbol (‘fruit13’, ‘fruit14’) but reels 2 and 3 also show stars (‘star23’). The outcome then is ‘hold23’ meaning that the player should hold the buttons for the two stars instead of the three buttons for the equal fruits. Similarly, if stars are present in reels 1 and 3, and the fruits in reel 2, 3, and 4 are equal, then the buttons 1 and 3 for the stars should be held.
5 Conclusion
We analysed the behaviour of slot machines and came to the conclusion that process specification and modal formulas are a suitable set of means to analyse them. Once set up, a formal model of the slot machine has several benefits. First, there is a clear and unambiguous description of the behaviour of the slot machine. Second, the specifications and formulas can easily be adapted to investigate variations of the slot machines or particular scenarios that players could employ. Third, the analysis via model checking computes exact values and therefore provides verified results. Fourth, the approach is compositional and therefore allows to model a complete slot machine by combining the models for the individual games. And finally, the player strategies can automatically be extracted, which allows better insights into the game mechanics.
While modeling the slot machines, we observed that it is not very easy to figure out what the exact rules of games are, not even for ‘simple’ slot machines. This is in line with what we found in board games as well [14]. It would therefore be useful to describe such games in a standardised formal way. This allows to communicate the rules of the games with gaming authorities that verify that the return-to-player is within acceptable and legal bounds.
5.1 Future work
There are a quite a few interesting aspects of slot machines that deserve further investigation.
Apart from the RTP, we could check whether the loss per hour is limited, even when a player employs a particularly bad strategy. Another question could be what the game characteristics are, when the player has a limited amount of money or a limited amount of rounds left. Note that the approach with quantitative modal logics is quite suitable to address such questions.
Using various tools we derived explicit optimal strategies for players, especially for variations of the reel game. These strategies are remarkably complex. In particular these strategies can take into account how many games the player is still planning to play. As yet, there are no easy ways to extract such strategies in the mCRL2 toolset, comparable to finding evidence and counter examples as can be provided for non-quantitive model checking [30]. It would be very useful to extend the quantitive checkers of mCRL2 with such capabilities, similar to e.g., [18, 24].
Another issue that can occur is that it can be computationally complex to evaluate a formula. This is essentially done by translating the specification and the formula to a parameterised real equation system that is subsequently solved [15] very much in line with how boolean formulas are solved using boolean equation systems [13]. But the size of these equation systems can grow rapidly. Solving formula (6) for requires more than 1M pres variables. Typical solutions here lie in using symbolic methods that can handle much larger systems, such as [25] for non-probabilistic and [23, 19] for probabilistic models.
Data availability.
The process descriptions of slot machines and the formulas are provided in the examples directory of the mCRL2 toolset (www.mcrl2.org) which is distributed under the liberal BOOST licence allowing its free use.
References
- [1] P. Ashok, M. Jackermeier, J. Kretínský, Ch. Weinhuber, M. Weininger, and M. Yadav. dtcontrol 2.0: Explainable strategy representation via decision tree learning steered by experts. In J.F. Groote and K.G. Larsen, editors, Tools and Algorithms for the Construction and Analysis of Systems - 27th International Conference, TACAS 2021, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2021, Luxembourg City, Luxembourg, March 27 - April 1, 2021, Proceedings, Part II, volume 12652 of Lecture Notes in Computer Science, pages 326–345. Springer, 2021.
- [2] I. Balabanov, Tand Zankinski and B. Shumanov. Slot machine RTP optimization and symbols wins equalization with discrete differential evolution. In I. Lirkov, S.D. Margenov, and J. Wasniewski, editors, Large-Scale Scientific Computing - 10th International Conference, LSSC 2015, Sozopol, Bulgaria, June 8-12, 2015. Revised Selected Papers, volume 9374 of Lecture Notes in Computer Science, pages 210–217. Springer, 2015.
- [3] T. Balabanov, I. Zankinski, and B. Shumanov. Slot machines RTP optimization with genetic algorithms. In I. Dimov, S. Fidanova, and I. Lirkov, editors, Numerical Methods and Applications - 8th International Conference, NMA 2014, Borovets, Bulgaria, August 20-24, 2014, Revised Selected Papers, volume 8962 of Lecture Notes in Computer Science, pages 55–61. Springer, 2014.
- [4] C. Barboianu. The mathematics of slots: Configurations, combinations, probabilities. Infarom Publishing, 2013.
- [5] G.D.I. Barr and I.N. Durbach. A Monte Carlo analysis of hypothetical multi-line slot machine play. International Gambling Studies, 8(3):265–280, 2008.
- [6] J.C. Bradfield and C. Stirling. Local model checking for infinite state spaces. Theor. Comput. Sci., 96(1):157–174, 1992.
- [7] S. Cranen, J.F. Groote, and M.A. Reniers. A linear translation from CTL* to the first-order modal -calculus. Theor. Comput. Sci., 412(28):3129–3139, 2011.
- [8] JVH Gaming/Errèl Industries B.V. JVH Gaming. marktleider met voorbeeldfunctie, Accessed April 2024. https://www.jvhgaming.com.
- [9] H. Garavel, F. Lang, R. Mateescu, and Wendelin Serwe. CADP 2011: a toolbox for the construction and analysis of distributed processes. Int. J. Softw. Tools Technol. Transf., 15(2):89–107, 2013.
- [10] T. Gawlitza and H. Seidl. Precise fixpoint computation through strategy iteration. In R. De Nicola, editor, Programming Languages and Systems, 16th European Symposium on Programming, ESOP 2007, Held as Part of the Joint European Conferences on Theory and Practics of Software, ETAPS 2007, Braga, Portugal, March 24 - April 1, 2007, Proceedings, volume 4421 of Lecture Notes in Computer Science, pages 300–315. Springer, 2007.
- [11] T.M. Gawlitza and H. Seidl. Solving systems of rational equations through strategy iteration. ACM Trans. Program. Lang. Syst., 33(3):11:1–11:48, 2011.
- [12] J.F. Groote and J.J.A. Keiren. Tutorial: Designing distributed software in mcrl2. In Kirstin Peters and Tim A. C. Willemse, editors, Formal Techniques for Distributed Objects, Components, and Systems - 41st IFIP WG 6.1 International Conference, FORTE 2021, Held as Part of the 16th International Federated Conference on Distributed Computing Techniques, DisCoTec 2021, Valletta, Malta, June 14-18, 2021, Proceedings, volume 12719 of Lecture Notes in Computer Science, pages 226–243. Springer, 2021.
- [13] J.F. Groote and M.R. Mousavi. Modeling and Analysis of Communicating Systems. MIT Press, 2014.
- [14] J.F. Groote, F. Wiedijk, and H. Zantema. A probabilistic analysis of the game of the goose. SIAM Rev., 58(1):143–155, 2016.
- [15] J.F. Groote and T.A.C. Willemse. Real equation systems with alternating fixed-points. In G.A. Pérez and J.-F. Raskin, editors, 34th International Conference on Concurrency Theory, CONCUR 2023, September 18-23, 2023, Antwerp, Belgium, volume 279 of LIPIcs, pages 28:1–28:17. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2023.
- [16] A. Hartmanns and H. Hermanns. The modest toolset: An integrated environment for quantitative modelling and verification. In E. Ábrahám and K. Havelund, editors, Tools and Algorithms for the Construction and Analysis of Systems - 20th International Conference, TACAS 2014, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2014, Grenoble, France, April 5-13, 2014. Proceedings, volume 8413 of Lecture Notes in Computer Science, pages 593–598. Springer, 2014.
- [17] M. Hennessy and R. Milner. On observing nondeterminism and concurrency. In J. W. de Bakker and Jan van Leeuwen, editors, Automata, Languages and Programming, 7th Colloquium, Noordweijkerhout, The Netherlands, July 14-18, 1980, Proceedings, volume 85 of Lecture Notes in Computer Science, pages 299–309. Springer, 1980.
- [18] C. Hensel, S. Junges, J.-P. Katoen, T. Quatmann, and M. Volk. The probabilistic model checker Storm. Int. J. Softw. Tools Technol. Transf., 24(4):589–610, 2022.
- [19] Ch. Hensel. The probabilistic model checker Storm: symbolic methods for probabilistic model checking. PhD thesis, RWTH Aachen University, Germany, 2018.
- [20] P.-A. Kamanas, A. Sifaleras, and N. Samaras. Slot machine RTP optimization using variable neighborhood search. Mathematical Problems in Engineering, 2021(1):8784065, 2021.
- [21] Kansspelautoriteit. Spelen op een speelautomaat, Accessed April 2024. https://kansspelautoriteit.nl/veilig-spelen/spelen-speelautomaat.
- [22] D. Keremedchiev, P. Tomov, and M. Barova. Slot machine base game evolutionary RTP optimization. In I. Dimov, I. Faragó, and L.G. Vulkov, editors, Numerical Analysis and Its Applications - 6th International Conference, NAA 2016, Lozenetz, Bulgaria, June 15-22, 2016, Revised Selected Papers, volume 10187 of Lecture Notes in Computer Science, pages 406–413, 2016.
- [23] M.Z. Kwiatkowska, G. Norman, and D. Parker. Probabilistic symbolic model checking with PRISM: a hybrid approach. Int. J. Softw. Tools Technol. Transf., 6(2):128–142, 2004.
- [24] M.Z. Kwiatkowska, G. Norman, and D. Parker. PRISM 4.0: Verification of probabilistic real-time systems. In G. Gopalakrishnan and S. Qadeer, editors, Computer Aided Verification - 23rd International Conference, CAV 2011, Snowbird, UT, USA, July 14-20, 2011. Proceedings, volume 6806 of Lecture Notes in Computer Science, pages 585–591. Springer, 2011.
- [25] M. Laveaux, W. Wesselink, and T.A.C. Willemse. On-the-fly solving for symbolic parity games. In Dana Fisman and Grigore Rosu, editors, Tools and Algorithms for the Construction and Analysis of Systems - 28th International Conference, TACAS 2022, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2022, Munich, Germany, April 2-7, 2022, Proceedings, Part II, volume 13244 of Lecture Notes in Computer Science, pages 137–155. Springer, 2022.
- [26] H. Mao, Y. Chen, M. Jaeger, T.D. Nielsen, K.G. Larsen, and B. Nielsen. Learning markov decision processes for model checking. In U. Fahrenberg, A. Legay, and C.R. Thrane, editors, Proceedings Quantities in Formal Methods, QFM 2012, Paris, France, 28 August 2012, volume 103 of EPTCS, pages 49–63, 2012.
- [27] R. Milner. A Calculus of Communicating Systems, volume 92 of Lecture Notes in Computer Science. Springer, 1980.
- [28] Gokkasten Online NL. Topspinner. https://www.gokkastenonline.nl/topspinner/. Accessed: June 2024.
- [29] Speelautomatenbesluit 2000, 2024. Regulations regarding slot machines, part of the Dutch Civil Code.
- [30] W. Wesselink and T.A.C. Willemse. Evidence extraction from parameterised boolean equation systems. In C. Benzmüller and J. Otten, editors, Proceedings of the 3rd International Workshop on Automated Reasoning in Quantified Non-Classical Logics (ARQNL 2018) affiliated with the International Joint Conference on Automated Reasoning (IJCAR 2018), Oxford, UK, July 18, 2018, volume 2095 of CEUR Workshop Proceedings, pages 86–100. CEUR-WS.org, 2018.