# What is Random Number Generation (RNG)?

**Virtually all casino games make use of random number generation, it’s what makes digitalised gambling possible.**

In the case of roulette, the wheel itself is the random number generator, and in dice games, it is the dice that provide the random element when they are thrown. In card games, the randomization of the cards is brought about by shuffling the pack, and in slot machines, an electronic device inside the cabinet produces random numbers that decide how long the reels will spin for.

In the case of online casino games, this variety of random number generators is replaced by computer-generated random numbers from which the results are derived. However, many people have called the supposed randomness of the results produced by the software that drives these games into question. After all, it is very easy to rig the results of a number generator in order to maximise profits for the casino website.

In this article, we shall take an in-depth look at how software-based random number generators work, how they are implemented in online casino games, and the implications of this for online casino gamers.

## Understanding Random Number Generation

**Whether they are hardware or software-based, the majority of Random Number Generators (RNGs) work on the same principle. **

Before we start, we should be clear on one issue, and that is that microprocessors are incapable of true random number generation. All they can do is to process an algorithm, which will give the same sequence of numbers if you give it the same number to start with. True randomness is only found in nature, although it may be possible with quantum computing.

There are several external sources of randomness that can be harnessed to create a true electronic RNG, such as radio noise, clock drift (the minute differences in the speed of advance between two clocks), or the timing of actual movements on a hard disk read-write head.

### Pseudo Random Number Generators (PRNGS)

Number generators that do not make use of an external input are known as Pseudo Random Number Generators (PRNGs), and it is these that are most commonly used in online casino games.

PRNGs use an algorithm, which is a complex series of mathematical instructions, to generate a long stream of numbers. Before it can generate the numbers, it will require an initial value to work from, known as a random seed number. The algorithm will then be used to compute the list of numbers using the random seed number as a basis.

Although the algorithms produce very long lists of numbers, the results are entirely pre-determined, and the same seed number will yield the same sequence every time. Theoretically, with a powerful computer and some specialised software, the sequence of numbers could be accurately predicted if the player knew the seed number and the algorithm being used.

The algorithms used by PRNGs are well-known and widely available on the internet, and you can find a list of the most common ones here. It is for this reason that the seed number must remain a secret. If the player knew both the seed number and the algorithm that is being applied, then they would be able to predict the outcome of the RNG with a high degree of accuracy – which would soon send the online casino out of business.

While true RNGs, as used by scientists and mathematicians to test probabilities, make use of exotic input sources such as atomic decay and thermal noise, software-based PRNGs have to make do with more prosaic seed sources, such as the time or date on the server’s internal clock. This means that the number generation is not really random at all, but there is sufficient variation inherent in these sources to give that impression.

The best-known, and most widely used PRNG algorithm in the world of online gambling is known as the Mersenne Twister. This algorithm was developed in 1997 by Japanese mathematicians Makoto Matsumoto and Takuju Nishimura. There are two versions of the algorithm, known as MT19937 and MT19937-64. Both of these produce sequences of numbers that are 219937 numbers long.

To put this into its proper perspective, try to imagine multiplying two by two, multiplying the result by two, and then repeating this last step nearly 20,000 times. The original algorithm, the MT19937, produces this number of 32-bit integers, which means that it is capable of producing a number between zero and just over four billion. The MT19937-64 produces the same number of 64-bit integers, which range between 0 and 1018, meaning that even greater variation is possible.

While the ability to produce huge lists of numbers can aid variation, it does not add any randomness to the process. However, it is preferable to shorter sequences of numbers, such as the 232 numbers that are produced by many other software-based number generators. Like all PRNGs, the Mersenne Twister requires input in the form of a seed number. However, online players should not make the mistake of thinking that the first number that comes up on a roulette wheel, for example, is the seed number, as the player has no idea how far along the sequence they are starting.

While no PRNG could ever claim true unpredictability, the bigger the numbers involved, the less predictable they seem to be. This is why the Mersenne Twister is capable of providing such a convincing illusion of randomness. Over the years, there have been several tests for determining whether an RNG is capable of truly random results that have been developed. The first was developed by mathematician Donald Knuth in 1969, and this was surpassed by the Diehard Test in 1995, which was developed by George Marsaglia, and the TestU01 software, which was released a decade later.

The Mersenne Twister comfortably passes the requirements of both the Knuth tests and the Diehard Test, and even passes most of the more stringent requirements of the TestU01 Crush test. This is why it has come to be regarded as the industry standard for pseudorandom number generation, as it appears to give results that are nearly as good as true random number generation.

## How is RNG Used in Casino Games?

**RNG is used in all online casino games, and also most modern slot machines, although it is applied in a variety of different ways. **

Generally speaking, their output needs to be greatly simplified in order to produce useful results. For example, in French roulette, which has pockets numbered from 0 to 36, the software has to produce an integer between 0 and 36 for each spin of the virtual wheel, based on an input number that could be anything from zero to several billion.

There are many ways in which the software can achieve this aim. For example, a 32-bit number, which could be anything from 0 to 4,294,967,295, could be simplified into a number between 0 and 36 using the following equation:

*Generated value / (Maximum possible value / 37) = Simplified Value*

So, if the RNG generated a 32-bit value of 2,000,000,000, this is how it would work out:

*2,000,000,000 / (4,294,968,295/36 = 119303437.0833) = 16.7638*

This would then be rounded up to 17. To give it parity with the numbers on the roulette wheel, it would be reduced in value by 1, and the number 16 would be the result of that spin of the wheel.

If the sequence of numbers was truly random, then there would be an equal probability of landing the same number the next time round. However, because we are dealing with a sequence of numbers created by the PRNG and then followed by the software, the chances of landing the same number again are very slightly reduced.

Higher bit depths and bigger lists of numbers mean that this reduction is less pronounced. However, it cannot remove this phenomenon entirely without the use of a true random number generator, such as one that makes use of radio noise as a key input. This would do away with the need for algorithms entirely, but it would be highly impractical with the current technology.

## RNG is Essential for a Variety of Games

### Roulette

Because roulette only requires one number per turn to be generated, it makes the simplest use of an RNG. Other games require more convoluted solutions. For example, dice games require several numbers between one and six for each turn, depending on the number of dice being thrown.

### Slots

Slot games typically require a number between one and twelve for each reel, so on a 5-column slot game, the RNG would be required to give five random values between one and twelve every time the ‘spin’ button is pressed.

### Card Games

The shuffling of virtual card decks is a little more convoluted, in that there are 52 cards in the deck and none of them can appear more than once. There are several ways in which this can be done, but perhaps the simplest is to get the RNG to produce a number between 1 and 52 to determine the card at the bottom or top of the deck.

In this instance, values of between 1 and 51 would be assigned to the remaining cards, and the RNG would then have to generate a number between 1 and 51 to determine the next card in the deck. This process would be repeated until there was only one card left, which would be placed at the bottom of the deck.

## Does RNG Mean that the Games are Fair?

**
**

**Although PRNGs such as the Mersenne Twister are not truly random, the high bit depth and long period of the sequence means that any differences between it and a true RNG are negligible in practice.**

** **

All things being equal, if you were to play a computer roulette game based on the Mersenne Twister algorithm, then the game would be just as fair as a real roulette table or an electronic roulette game based on a true RNG.

However, there are a number of ways in which online casinos can rig games in their favour. One way would be simply to change the sequence of numbers. While this could be made to work in the casino’s favour, for example by removing some of the jackpot symbol-triggering numbers on a slot game, it would also make it easier for a clued-up player, with the aid of special software, to identify patterns and use them to predict which numbers are going to come up.

Alternatively, if an online roulette player bet on the number 33, and the RNG turns up the number 33, an honest roulette game would automatically display the winning number and credit the player.

### Beware of the Fraudsters

However, a crooked roulette game might contain a piece of code which recognises when the player has won and then use that as a cue to generate another number and display that instead. It could also be set up to only do this in certain situations, such as on every second or third win, so as not to give the game away.

This type of fraud is not unknown in the world of online casino gaming. The highest-profile case in recent times involved a software company called BLR Technologies, which at the time provided gaming software to several online casinos including Legends.com, 5Dimes, and World Wide Wagering.

The fraud was uncovered in 2008 by Norman Clem, 66, of Las Vegas. He had been playing craps at World Wide for about a year before he suddenly hit a losing streak. Something about the persistence of this losing streak struck this experienced player as suspicious, so he started recording his bets to assess the win percentage. All in all, he recorded 3,200 simple “pass” or “don’t pass” line bets, which should win almost 49% of the time. However, Clem found that he only won 856 times, a win rate of just 27%, and posted his findings on an online forum.

Clem’s postings intrigued online gambling consultant Michael Shackleford, also known as ‘The Wizard of Odds’, and Eliot Jacobsen of Jacobsen Gaming, an online gaming auditor. They both set about performing their own tests on sites that used BLR software, and came to the same conclusion – that BLR was rigging its craps games to dramatically increase the house edge.

Short of performing your own exhaustive (not to mention expensive) tests, how can you tell if an online casino is using rigged software? Thankfully, there are independent regulatory bodies whose job it is to root out online fraud. If an online casino is audited by one of the main worldwide gambling regulators, such as eCogra, then you can be assured that the games are fair, and that a casino’s payout percentages are roughly in line with the published odds, and that their software and number sequences have been inspected for any signs of foul play.

Therefore, before signing up to play at an online casino, it is thoroughly recommended that you look on the ‘about’ page to find out if the casino is audited by one of the main regulators, and then check that against the listings on the website of those regulators to check that this information is accurate. Click here to see a full list of regulatory bodies and auditors for the online gaming industry.