Key Takeaway

RNG stands for “Random Number Generator.” A Random Number Generator is a function that picks a random number from a predetermined range. RNGs are implemented in video games to choose an outcome outside of a player’s control.

RNG in gaming stands for “Random Number Generator.” While this is a straightforward name for the function, the finer details of how it actually works are often hidden in a game’s coding. Thankfully, the concept can be broken down easily.

#### Table Of Contents

## What Is a Random Number Generator (RNG)?

A Random Number Generator is a function that picks a random number from a predetermined range. The simplest version of such a function is to have the range be two outcomes with nothing else in between them. Flipping a coin would be a good example of this (both inside and outside of video games).

Most often, when you flip a coin, there are only two possible outcomes: heads or tails. The majority of the time, the results of a coin flip will bluntly result in total success or utter failure.

However, RNG in gaming tends to get much more complex. The range of possible outcomes is much greater and there may even be secondary functions that get triggered from certain outcomes—which can activate another RNG. As such, there can be a cascade of effects that results from taking a single action.

## Simple RNGs in Gaming

Adding unpredictability to video games makes things less straightforward. With more variables comes more choices, outcomes, and events—all of which increase the difficulty. However, this also makes one’s quest feel like a true adventure, as unknown factors add some excitement.

Great examples of an RNG in gaming can be found in *Darkest Dungeon*. There are both simple and complex RNGs in this game, although, for now, let’s just take a look at one of the simple ones.

In the combat of this game, there are chances to both hit and miss attacks. This is true for both the player and the AI enemies. Furthermore, the stats involved in such calculations can partially be seen by the player.

When a member of your party is being attacked by a foe, your party member’s Dodge stat gets subtracted from the enemy’s Accuracy stat. These stats represent percentage values, so things are pretty easy to calculate.

In *Darkest Dungeon*, every hero and enemy attack has a base 95% chance to hit. Therefore, if there are no extra variables, a character with a Dodge stat of 10 will be 85% likely to get hit by an enemy’s attack. This is because the hero’s Dodge stat of 10 (equal to 10%) is being subtracted from the enemy’s base accuracy of 95%. Here’s how the process looks in equation form:

- 95% – 10% = 85%

When the game sees that a hero has an 85% chance to get hit, the RNG is activated to determine whether your hero gets hit or not. Since the game is using percentages for the Dodge and Accuracy mechanics, the natural range is from 0 to 100 (if there are no extra variables).

The game will take into consideration the hero’s Dodge stat and the enemy’s Accuracy stat before rolling the digital die. Here’s a breakdown of what happens:

- If the value rolled is between 0 to 85, the hero will get hit by the attack
- If the value rolled is between 86 and 100, the hero will not get hit by the attack

## Complex RNG in Gaming

In addition to being used in combat and events, RNG in gaming can determine how successful you are when you perform any action. To explore how video games can implement this in gameplay, let’s take a look at the Fortune enchantment in *Minecraft*.

Normally, when you break a block of Diamond Ore with an Iron Pickaxe (or better), you’ll get one Diamond. However, if your Pickaxe is enchanted with Fortune, you can potentially get more than a single Diamond.

There are three levels of the Fortune enchantment: level 1, level 2, and level 3. Fortune I can let you get up to 2 Diamonds, Fortune II can let you get up to 3 Diamonds, and Fortune III can let you get up to 4 Diamonds. Although, the greater gains are percentage based and not guaranteed.

Fortune I has a 33% chance to multiply the Diamonds dropped by 2. Then, Fortune II has a 25% chance to multiply the Diamonds dropped by 2 and a 25% to multiply the Diamonds dropped by 3 (50% chance of increased drops). Next, Fortune III has a 20% chance to multiply the Diamonds dropped by 2, a 20% chance to multiply the Diamonds dropped by 3, and a 20% chance to multiply the Diamonds dropped by 4 (60% chance of increased drops).

Like with *Darkest Dungeon*‘s Dodge mechanic, the Fortune mechanic in *Minecraft* operates using percentages—albeit in a more complex manner. As such, the game will be using a value range between 0 and 100.

If your Pickaxe isn’t enchanted with Fortune, the RNG has a pretty easy job in that it does nothing. Here’s what the game will do in such a case:

- If the player breaks Diamond Ore with the right tool (proper break occurs), the player gets 1 Diamond Ore (100% chance)

Now, let’s take a look at what the RNG does if the player’s Pickaxe has Fortune I:

- If a proper break occurs, the game rolls for how many Diamonds drop
- If value rolled is between 0 and 33, the player gets 2 Diamonds
- If value rolled is between 34 and 100, the player gets 1 Diamond

Comparatively, let’s now look at what the RNG does if the player’s Pickaxe has Fortune II:

- If a proper break occurs, the game rolls for how many Diamonds drop
- If value rolled is between 0 and 25, the player gets 2 Diamonds
- If value rolled is between 26 and 50, the player gets 3 Diamonds
- If value rolled is between 51 and 100, the player gets 1 Diamond

Finally, let’s see how things look when the RNG needs to factor in a player’s Pickaxe that has Fortune III:

- If a proper break occurs, the game rolls for how many Diamonds drop
- If value rolled is between 0 and 20, the player gets 2 Diamonds
- If value rolled is between 21 and 40, the player gets 3 Diamonds
- If value rolled is between 41 and 60, the player gets 4 Diamonds
- If value rolled is between 61 and 100, the player gets 1 Diamond

## Where Did RNGs Come From?

Arguably the oldest appearance of dice in a physical game was in the ancient Egyptian game known as Senet. Here, players would roll dice (or sticks) to see who goes first. Furthermore, dice or stick rolls would also be done when moving one’s game pieces.

Senet was a simple board game where two opposing players would have five pawns each. The board played on would have 30 spaces and the winner was determined by whoever got to the end of the board first. This made how far players could move during their turns vital to winning. As such, the outcome of dice or stick rolls was crucial.

The first appearance of Senet has been traced back to around 3100 BCE. Evidence of the game was found in the burial tombs of First Dynasty rulers. Images and text on the inner walls of the tomb depicted people playing Senet.

Since dice (or sticks) were the first appearance of random factors being implemented in a game, Senet can be considered the first game with any sort of pre-computing era RNGs.

## The Oldest Video Game With RNGs

From the inception of video games, variables were an important feature. However, long ago, these variables were considerably simpler than most things seen today.

So what was the first RNG in gaming? The question mark block in *Super Mario Bros.*? Nope. The drop rate of Rupees from the tall grass in *The Legend of Zelda*? Not quite. How about the paths of the falling barrels in *Donkey Kong*? Close, but that’s not it either.

The first appearance of an RNG in gaming goes all the way back to 1958 in a title that’s known as the first true video game ever created: *Tennis for Two*.

In *Tennis for Two*, players would play a tennis game much like *Pong*, but with a bit more complexity. The random factors come in when the player hits the ball, which is then subjected to factors like wind resistance. After the ball is struck, the game calculates the direction and speed of the ball and takes into account the wind.

While that in itself isn’t RNG dependent, the wind itself is. Which direction the wind blows can be considered the first time a video game has forced a player to deal with unexpected variables: random number generation.

It has never been fully disclosed how *Tennis for Two*‘s wind is generated, however, due to the limits of technology at the time, it can be assumed that the direction of the wind was chosen randomly.

## The Pros and Cons of RNG

These days, gamers have a lot more to deal with than just the direction of the wind. When looking at combat-related games, critical hits are one of the most infamous for angering players.

For example, take *Pokémon* battles. There are a lot of calculations and variables that determine how much damage the opposing pocket monsters do to each other. Knowing how much damage you’ll unleash and how much you’ll take is crucial to victory.

However, even if you are able to mentally figure out such values exactly, there’s always a chance that your opponent may get lucky and land a critical hit—which can knock out your active Pokémon.

Conversely, you can also get lucky and land a critical hit on your opponent, which would turn the tide in your favor. When this happens, there is no anger, but unexpected joy. These same lows and highs appear in many other games that pit players against one another.

Just like in the games of Senet that happened thousands of years ago, random factors can both help and hinder you.

## A Balance of Skill and Luck

While many gamers out there curse RNGs for devaluing their skill at a given game, there’s more to consider.

RNG in gaming is not the only random factor at play. How the player is feeling when gaming, mentally and physically, is also random. Sometimes you wake up and feel great; ready to take on the world. However, on other days, you’ll barely feel like getting out of bed.

What’s more, the state of technology also has random factors. Sometimes, controllers and keyboards malfunction. Other times, a game can crash. Such things are mostly out of the players’ control.

Luck isn’t something that only exists in the coding of video games but in every aspect of life. In this regard, it’s appropriate for random factors to be in video games, as this echoes how things are in real life. While video games are often thought of as escapes from the real world, they are still sometimes based on things in the real world.

The risk of poor outcomes puts our senses on edge and the relief of getting a good outcome releases this tension. Unexpected outcomes always make things more interesting—for better or worse. A balance of stressful moments and calm ones are important to have for gameplay, as interest is what keeps players playing games.