“Accidents are not random, all this is a big deception.”Or how the elements of the random in games work.
Good day Stopgame! Today I will tell you how the elements of the random (random events) work and how in fact the developers create certain situations where these elements are required. I will immediately clarify for a greater understanding: chance – random. I will try to tell as much as possible and understandable for perception. Well, let’s go!
About the types of random elements
Few know, but A computer cannot create a completely random number, What algorithms would not be used. The always created number will depend on something and will not be completely random. A computer is a machine and it obeys mathematical algorithms and formulas, and an accident, in principle, the direct opposite of some mathematical rules. The developers always go to the tricks in order to create the illusion of chance as plausible as possible, but this still cannot be called a complete random.
In fact, there are several situations where the use of random elements is required:
1.Procedural generation (creating landscape and worlds).
2.”Honest” generation of objects (the loss of objects from opponents, chests, etc.).
3.”Not honest” generation of objects (cases in games bought for real money).
4.Situations where the whole game is tied on the elements of the random. (Playing cards, games with a hexagonal cube)
5.Various situations that should occur in random times (for example, changing the weather from sunny to rainy).
Let us dwell on each highlighted element in more detail. (if I forgot to add something to the list, I am mercy in the commentary. If there is a really interesting and constructive comment, I will complement the blog).
Procedure generation
Of course, this word means not only the creation of a landscape and environment, this includes the whereabouts of objects on location, characters and much more, but still the most popular method of use is the generation of random worlds still remains. A striking example is the creation of the world in Minecraft, where it is precisely a procedural generation, She creates absolutely the whole environment around the player (all blocks, chests, enemies, objects, characters, etc.) and let’s figure out how it is created. In fact, the algorithm has changed more than once, but today it works like this:
Did you know that the Professor Wins Casino review world in Minecraft is not endless? It is 30 by 30 million blocks. When generating (not only in Minecraft, many games also) use the so -called “Seed” – initial value.
To create a unique world, it is the initial meaning to create from random numbers and symbols. Almost no method does not work without it GPSCh (Pseudo -Labor Number generator). But since, the computer cannot create anything random, The game takes for random numbers the date and time on the computer. If you try to create two worlds in the game with the same date and time (for example, 20.10.2020, 18:34), then get two exactly the same world. But the creation of “Seed” does not end, then this initial value is converted into a 32-bit number by several formulas. After that, the number is obtained, which applies to another method – Noise Perlin.
Perlin’s noise actually has nothing to do with the sound, this is essentially a picture (an example in the image below) with many shades of gray, white and black colors.Speaking in a very simple language, the darker the pixel in the image of the noise of Perlin, the higher (or lower) the landscape is created.
Suppose such an example (very simplified, in fact everything is more complicated, there is a bunch of “filters” of the subsequent “polishing” of the world). There are pixels in the picture of noise only three colors (without shades): white, gray and black, then the world “minecraft” can generate a maximum of 3 blocks with an altitude of a height. White will be a block of air (in fact the absence of a block), gray the thickness of the landscape in 1 block, and black thickness in 2 blocks. But such a noise of Perlin is customary to call two -dimensional.
The game uses mainly three -dimensional noise (3D) (but the two -dimensional also works for “polishing”), since when using only two -dimensional (2D) it would be impossible to create for example caves and various buildings. Below you can see 2D noise. In the first picture, you see the noise itself on the left, and on the right the result of the creation (unsuccessful I found an example, some 2D game is created on the right). In the second picture, you immediately see the result of the work of the noise of Perlin already in the game engine. The third and fourth picture shows more and more clear.
This is how all the procedural-refined worlds are created, the noise of Perlin, together with the algorithms of pseudo-service numbers, remain perhaps the most popular and simple. I tried to describe as clearly as possible, but I admit that it is still too difficult for perception. Write in the comments, if it is not clear, I will modify the blog. Well, we will move on to the next element of chance. In more detail and many times more interestingly about procedural generation, you can find out from the video below:
“Honest” and “dishonest” generation of objects.
What I mean by the word “honest”? Honest I call the generation of objects that does not depend on server data and the probability of falling out such items is generated by a engine, and not by developers or publishers.
Let’s give a conditional example: you have a game in which there are 4 types of rarity of any thing: ordinary, rare, epic and legendary. For example, you approach the chest, where these things will fall out to you and the system will be honest where the randomness algorithm does not change by the developers after the release if desired. That is, if you have for example a legendary item, then you are “lucky”, since the right number has fallen in the algorithm, if not, then the probability of the loss of this subject will not change based on the past object obtained.
Simplified this system works as follows: let the probability of objects of objects is the same – ordinary (70%), rare (20%), epic (9%), legendary (1%). All this in total gives a 100% probability, and then the algorithm will look so conditional like this: if accidentally introduced It is located from 0 to 70, an ordinary item will fall out, if from 71 to 90, a rare object will fall out if an epic object will fall from 91 to 99, and if the introduced number 100 falls out the legendary. The element of the random here is the most introduced number. Where to get this random number? There are actually a lot of ways: from the previously mentioned SEEDA (just take its last two numbers), before listening to atmospheric noise and the noise of the microphone for its subsequent transformation into a digital form (this is how the popular site works: Random.Org).
However, Stopgame is a game portal, so let’s find out how such numbers are generated in two most popular game engines: Unity and Unreal Engine.
-In these engines, one of the methods uses “Xorshift”, which takes the date and time on the PC, then converts the resulting number into a binary number system, then summarizes this number several times with a shift to the right and left, after the resulting number is cut down in terms of the initial length and it turns out a pseudo -randomic number. More clearly and in detail about this method is described in the video below.
Let’s now talk about the “dishonest” generation of objects.
This method is the most widespread in online games: “Warface”, “Overwatch” and “CS: GO”. They also use the principle based on probability, as in the “honest” method, only unlike it the dishonest method changes its likelihood depending on the previously obtained data. Now the language is simpler: if you have a “legendary” thing with a chance of 1%, then the next “legendary” thing will already have a chance of falling out, for example 0.5% or less, and the “ordinary” things with a chance of 70%, on the contrary, will raise their chance of falling out to be up to 80%, so after several attempts to discover the conditional “cases in CS: GO” the chance will increase until it reaches its maximum of 1%, and the probability of a “ordinary” thing is not dropped to 70%.
Naturally, a dishonest way, as a rule, is needed in order to make a profit from the players, because excitement and the ghostly hope that “soon the legend will fall, I feel” and makes the players spend money on this kind of case, roulette, bets and casinos. The whole process is controlled by the developers and they can change the probability parameters at any time, since all the algorithms are on a remote server. Let’s talk about the next element of the random now.
Situations where the whole game is tied on the elements of the random:
I’m talking about those games where your victory directly depends on the originally (or in the process) of the resulting random combination of elements. The most striking example of this in real life is playing cards. A person mixes the cards with his hands, then distributes them to all the players. But how can a computer mix cards? In fact, you can use a very strange, but working method: tracking the movements of the mouse arrow.(I don’t know if this method is used specifically in specifically in card games, but in many projects it is present). The computer tracks the coordinates X and Y, on which the mouse is now located and takes only according to the last number from each coordinate. Suppose an arrow of the mouse is on the coordinates x = 54 and y = 27. The algorithm will take only 4 (out of number 54) and 7 (out of number 27) to create a random number, then there can be many functions, the number can be added, subtract, multiplied, divided and obtained by any other new pseudoic number. Further, the cards are numbered from 0 to 36, we add up previously received 4 and 7, we get 11, so the player will get a map under the number 11 from the deck and so, until the players receive the right number of cards. Naturally, all the mouse movements are monitored in a minute of time, because if you look at the current mouse coordinate each time, the pseudo -liable number will always be the same if the mouse does not move.
I really hope that you understood what I wanted to say, I tried to explain clearly, but my manner of speech and narratives of course “leaves much to be desired”.
Let’s move on to the last element of the random, which I was able to formulate.
Various situations that should occur in random times.
In the example, you can bring rain and a thunderstorm from the same “minecraft”. In fact, there is no accident there, the frequency of rains depends on the same “ill -fated” SEED, which was created during the generation of the world. With certain SEEDAH, the rainy period changes, thanks to the calculations according to certain formulas (which “Mojang” does not show). Roughly speaking in the same world, with one Seed rains, they take place once in the game 5 days, in another world, with another SEED, frequency will already be, for example, in the game 7 days. There are no elements of the random at all, everything happens naturally and according to the formulas.
Really random situations in games are used very rarely, but still present. Let’s analyze their work.
Take as an example of wandering merchants in Dying Light. I can’t accurately assure that the whole worker is exactly the way I say, since ordinary users have no access to the “engine” source code, but everything hints at this method.Merchants appear in random times (which is determined through the GSPF) with random goods in a random place. But here, unfortunately, there is no random element in the present. Merchants appear in specially prepared places that the developers have chosen for them, and sell goods, which is also not accidentally generated (the goods are created from specially prepared sets of objects, which the developers also managed to make earlier). Also, prices for goods can change in a larger or smaller side with just one formula (decreasing interest to the original price of goods), thereby attracting the player with a “temporary discount and limited offer”, but all this is only an illusion of deception.
I would like to believe that you do not think about the wasting time spent by reading this blog, I tried to do clearly and interestingly, but it turned out “as always” badly. I do not say goodbye, we will see you in the vastness of Stopgame.ru
Leave a Reply