Anyone that has played a modern video slot machine, or even a slot machine mobile app, has probably noticed a game mechanic that the classic (read physical) slot machines are simply incapable of. That is, of course, the bonus round or bonus game.
This mechanic offers the player a chance to earn extra winnings as a result of a special spin, or gives them to earn a multiplier bonus to their next or previous spin. Ultimately, the goal is to break up the repetition of the normal play mode and add some ‘eye candy’ to the game to keep the player’s interest.
In this article, We will look at the core programming that go into one style of these bonus rounds. For this, we will be using the somewhat predetermined ‘scratch ticket’ style of pick game.
The programming rules are as follows: 1) One a bet is placed, a Win Level then a Multiplier Amount will be Determined at Random. 2) Multiplier will applied to the Bet Amount as Winnings. 3) Winnings will be divided into a list of between 1 and number of available Pick Locations -1. 4) Each Pick Location will pull the next Amount from the list until the full Winnings have be uncovered.
We can divide this up in our code into four methods that should be fairly simple. First, Let’s look at getting the Win Level.
In the Method I have named GetOdds(), we use three values set by the designer to determine the chances of getting into one of the three win levels. We use RNG (random number generation) to get a number between 0 and 99. In this code, the lowerer the number the better the result. Once we have our Win Level, we call the next Method.
In GetMultiplier(), We take the integer Identifier from GetOdds() and use it a Switch statement. There we use RNG again to pick from an array of Multipliers in a given Win Level. Once we have the Multiplier, we use it with the Bet to determine the winnings. And move into the next Method.
Note that Case 0 is different from the others because this is the Case in which the player does not win a bonus at all. Here we call a Method in the UIManager to let the Player know what happened.
With SplitWinnings(), we are selecting a random number of boxes to put the winnings in. Since, the last box the play picks has to always be a dud and this build has nine possible boxes to pick from, we will get a random number between 1 and 8 to set the size of the array that we divide the winnings into.
As for the actual splitting, we will use a While loop. Before each iteration of the loop, it checks the total Sum of the against the Winnings. Once they are equal the loop stop. Meanwhile, we randomly pick one of the spots in the array and add the Minimum Bet Increment to it. And to avoid any extra Floating Point mess, we round off the current slots amount each time it is added to. In this case, we are rounding to the nearest cent with the Minimum Increment being five cents.
Adding in some simple UI and tying it into the mechanics we built, we get the prototype of a Bonus game. Ideally, we would make a splashier UI and have it return to the Casino Game after the first Winnings are added to the balance. But this is a stand alone demo and gets the concept across.