Theorver is not needed in games, but this is not certain

Probability theory is one of the important parts of not only game design; strictly scripted events without options will quickly cause boredom among players. I only had one year of this discipline at university, and I can’t say that I need to apply it every day, but when I need to explain basic knowledge to designers, I have to deal with the fact that each designer understands probability theory in his own way. These thoughts of mine appeared after a discussion with one of my colleagues wonderful article Jan Schreiber on non-random accidents and broken RNGs in games. Games are huge non-deterministic systems, regardless of whether this was included in the design or not. And understanding the nature of randomness to control those systems that impact the player's experience helps design them so they don't feel nailed down. If there is randomness in the system, you need to understand how to change it, bringing it closer to the everyday understanding of the players. And even if all the mechanics of the game are strictly deterministic, their interaction gives a random result, as you can see by watching numerous videos on various hacks of game systems.


Toss a coin

At its simplest level, probability theory deals with the “odds” or “probable outcomes” of something happening. This is expressed by some number from 0 to 100, if it is more convenient for you, let there be percentages. If something has a 100% chance of happening, then this event will definitely happen, 50% means that it is equally likely to happen or not to happen in a single observation.

The coin example works best. You flip a coin and see which side comes up. What happens on the first throw? It will come up heads or tails, the conditional case will hang in the air and stand on its edge, we do not consider it. Let's say heads didn't come up, the event that heads didn't happen with a probability of 50%. Let's continue tossing the coin.

Heads on the first throw and heads on the second throw (OO)
Heads on the first throw and tails on the second throw (OP)
Tails on the first throw and heads on the second throw (RO)
Tails on the first throw and tails on the second throw (PP)

In two rolls there will be four possible results, two tails, two heads, or heads and tails, but because we perceive OP and RO as the same, the appearance of getting it is higher. Thus, the probability of each of these four outcomes is 0.25 or 25%. If you add up the probabilities of all four outcomes, you get:

0.25 (OO) + 0.25 (OR) + 0.25 (RO) + 0.25 (RR) = 1 or 100%

If you keep tossing the same coin for a long enough time, some toss will land on heads. This is what probability theory says. If you add up all the chances of the outcomes of this experiment, the result will always be 100%. The analogue of coins with game mechanics is direct and obvious, if you have two mechanics that affect the player, and these two mechanics have only two states, then at the end you will already have 4 possible states.

A little more complicated

For example, in our hypothetical game, a box might contain ammo, food, and a first aid kit. The player can obtain each item with the same probability. What is the chance that the player will receive ammo? That's right, ~33% or 1/3 and the player takes out cartridges from the first box. What is the chance that the player will receive a first aid kit from the second box? That's right, 1/3 and from the second box the player takes out cartridges again… Stop, stop, says the designer, we have already given him cartridges, now we need to give him a first aid kit or food. And he writes a task to the programmer that “your random number generator is not working correctly,” because the chance of getting a first aid kit is set to 1/3, and the boxes give out ammo more often.

Returning to the coin – if we continue to flip the coin, we will observe successive probabilities. The probability of events occurring one after the other can be determined by multiplying the odds of those events occurring. For example, the probability of getting two heads in a row is 25%. This is 50% for the first roll, multiplied by 50% for the second.

Probability of getting two heads in a row = 0.5 x 0.5 = 0.25 or 25%.
Probability of getting three heads in a row = 0.5 x 0.5 x 0.5 = 0.125 or 12.5%.

Same with the first aid kit, when opening a certain box the player will still receive it, but it will not necessarily be the second one. Understanding sequential probabilities is an important aspect of probability theory and helps estimate the chances of specific events occurring in the future based on the probabilities of the individual component events. Answering the designer’s question about a broken RNG for the first aid kit and ammo, he was asked to write the table he needed for the probabilities of certain items dropping out, which were then put into the correct item issuance generator.

Joint and non-joint events

These are events that may or may not happen simultaneously. For example, you cannot get both heads and tails when tossing a coin. But you can get both cartridges and a first aid kit in the box, but if the designer for some reason decided that the box cannot contain both cartridges and food at the same time, then this event is incompatible. Or another example, the loss of two identical cards at the same time (for example, two aces of spades or two kings of hearts) in one hand. When applied to video games, this would be the simultaneous completion of two different tasks that can only be completed sequentially. Very often they forget about this and do not check it, which leads to quest freezes, logical errors, etc.

In the small box example, it is easy to simply count the successes and failures. But in a large set of data, which is the game and quests in it, it is not always possible to calculate all possible results, this is usually done Technical System Designerwhose main task will be to configure and balance various game parameters and mechanics to ensure an interesting and “fair” gaming experience.

Dependent and independent events

If you look at a two-dice system, the roll of each die does not depend on the outcome of the other, nor does it affect it. Just like the chance of throwing heads does not depend on the result of previous coin flips, and the phase of the moon does not affect either, but this is not certain. And in general, the state of the system, whether cubes or coins, does not depend on the state of its individual parts. But there are systems where the state of the system changes after an experiment and affects the probability of subsequent random events. Such a system, known to everyone, will be an ordinary deck of cards; removing one card changes the state of the system, redistributing the chances. For example, we want to get a ten of clubs with the first card, the probability of this event in a randomly assembled deck will be 1/36, but the chance of getting the same card in the second experiment will be 1/35.

The chance of getting the ten of clubs on the second move will be (1/36 + 1/35).

But let's say that we want to get a ten of any suit in the first two moves, then the formula will take the form 4/36 + 4/35. The addition here comes from the fact that we want to get the result in two attempts. If we set a condition to get any two tens on the first moves, then the chance of such an event will be 4/36 * 3/35, the multiplication here is obtained due to the fact that we count the chance of two tens falling out one after another.

Checkmate waiting

Our experienced (he is definitely experienced, if only because he keeps such tables) technical designer made a table of event probabilities for damage from a new monster, which is calculated based on the hexagon roll. Then you can get the average value of this event during multiple experiments and calculate it.

n∑i=1 xi⋅pi

1 * 1/ 6 + 2 * 1/6 + … + 6 * 1/6 = 1/6 * ( 1+2+3+4+5+6) = 3.5

This means that for six attacks of the new monster, adding up all the results, we will get a total of 3.5 or a value close to it. This is important knowledge because all modern games build balance based on these calculations.

Now let’s imagine that the monster is undergoing review, and the testing department doesn’t like this approach, “my friend hits too weakly, it’s not interesting to play,” they say. The monster's attack is increased from 10 to 20 units, but random damage is left in this range, and they are slightly tweaked so that each attack unit falls only once. The mathematical expectation of damage in this case will be equal to: mathematical expectation of damage = (10 + … + 20)/10 = 16. And the designers build the parameters of the conditional shield, health and perks of the monster from this number.

Another example:

If you have a 70% chance of hitting the enemy, then the expected number of hits with 10 shots will be:

Mathematical expectation of hits = 10 x 0.7 = 7

The average expected number of hits will be 7 out of 10 shots. Based on this data, the designer builds a table of armor, life and other parameters so that the enemies survive a couple of minutes in battle. Have you been playing counter and handing out headshots? Great, but your friend is not, together you shoot for seven 🙂

Pseudo-random events

In computer shooters (this is true for other games, but now I just have more data for shooters specifically), pseudo-random distribution (PRD) is used to determine the likelihood of various game mechanics, ranging from damage, critical hits, and ending with perks. Unlike fair randomness, where each “shot” is completely independent, in the PSR the probability of triggering increases with each unsuccessful “shot”. This means that the more you miss (such as a perk or critical hit), the more likely it is that the next “shot” will trigger. Thus, in the PSR, the triggering of game perks becomes more consistent and predictable compared to random. Typically, the probability of a certain effect triggering after the Nth shot is determined by the formula P(N)=CxN. For each individual shot that can trigger a perk, the pseudo-random distribution increases the probability of it triggering by a constant WITH, if previous shots did not activate this perk. Once the perk is activated, the counter is reset.

Effects based on pseudo-random distribution will not trigger too rarely or often. This gives the game more predictability compared to completely random distribution. However, in the game itself, predicting the triggering of an effect based on a pseudo-random distribution will still be difficult, and it will be defined by the player as “truly random” or “fair random”. Theoretically, it is possible to increase the chance of, for example, a critical hit by shooting at enemies without activating the pseudo-random distribution, but in practice this is difficult to achieve. If you shoot at targets where this effect cannot trigger (such as buildings or protected objects), the chance of it triggering does not increase. Thus, a player with a weapon that has a critical effect by shooting at buildings will not increase the chance of a critical hit with the next shot, since this effect does not apply to these objects.

Myths about increasing odds in games

We don’t take the casino into account; everything has been calculated there long ago and there is no room left for chance. But game designers are well aware of the misconception people have about random events; players believe that the probability of some event increases over time. For example, when throwing a die, you expect a six to come up, you throw it over and over again, if you do not mark the number of throws, your brain will successfully “weed out” a couple of unsuccessful throws, then the long-awaited six will roll out and we take this as an “increase in probability.” If the events are statistically independent, for example, dice rolls, then our expectations do not affect the outcome of the roll in any way, and there is no increase in probability.

It’s just our brain playing with us so as not to get too upset. Game developers, knowing this peculiarity of human perception of random events, can also adjust the chance of getting a 6 with the number of rolls, so as not to upset the players. Because an honest random is dishonest in the opinion of most players. But there is one more feature: this effect is almost unnoticeable in short gaming sessions (from 1 to 3 minutes), and the shorter the session, the more loyal the players are to truly random events.

If you hear from a friend that he needs fair randomness in the game, most likely he just doesn’t like the game. People want to have fun from the game, in this case fairness, if we are talking about randomness, is the last thing they care about. When you ask your friend why he needs an “honest random”, you will hear that he gets the conventional sword, ammunition and first aid kit, so necessary for passing, in 15 or even more attempts, or gets unnecessary items every 5-6 chests. One could argue that “fair random” will equalize everyone sooner or later, but whether this will happen in your game is a big question. And all this talk about “fair and dishonest randomness” boils down to one solution – “give the right item on the tenth try” for each specific player. Luck configured in this way will coincide with the expectations and everyday ideas of the players, making them happy.

Games are complex non-deterministic systems

Most games are too complex to create complete probability tables for even any part of them, let alone write a sane analysis based on these tables. For example: the strategy table for playing flip has 20 decision points and expands 3 times for each player. The decision table for a simple text quest with three parts and one ending is more than 30 points. I've been playing for sooooo long, I might have forgotten something.

Amnesia (CR 1):
You need to cope with memory loss and other problems that hang over you…
There is only one solution, three parts: spaceport, bar, bunker.

Go to the spaceport, search your own ship (you will find a stunner), go to the grocery store, buy a bottle of vodka, go to the hunting store, buy everything you can.
Now – to the orderly's house, go to the orderly, listen to the voices from different apartments, stun him with a stunner, demand a weapon, ask who robbed the apartment, finish off the bearing, give the bearing-policeman a bottle of vodka.
Next – go to the Golden Lily bar, talk to the Haalian, go to the hunting store, tell the seller the password, go to the bar, approach the bearing, let the Haalian go ahead, carefully walk around the house from behind, order the Haalian to attack the left enemy, and shoot at the right one , go into the house, go down to the bunker, and shoot the Pelengs together with the Gaalian.
Calculate the lock code using the formula: X=(10*(2^n))-10 n – number of days, open the door and leave the room, go into the nearest door, paralyze the malok with a stunner, go down to the floor below, throw down the weapon and surrender .

But even if a complete analysis of quests and events in the game is out of the question, we can still use elements of probability theory to set up various mechanics, which events are likely, unlikely and impossible.

Also, knowing the tendency of players to overestimate their skills in games, you can “tweak” the probability of random events depending on the style of play. The everyday understanding of the essence of the probability of events by players allows developers to approach the system of random events in games in different ways.

conclusions

  • What comes to the fore is the designer's ability to explain randomness with game events and rules so that the experience meets expectations. If a challenge/quest/combat seems too easy, or too difficult, the game will be frustrating. The opposite is also true: shots that always hit at sniper range are just as frustrating as consistently missing shots.

  • If a game's random events are hidden, honestly random, or poorly explained, then the game won't be fun. I am not currently considering a separate category of players who like this. Too many random events cause misunderstanding, too much understanding, it becomes predictable and boring.

  • The pleasure comes from a balanced amount of surprises and understandable moments. All this means that randomness in games needs to be managed by showing players not just random events, but clear and explainable decisions. But this is a topic for another article.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *