Dice generator - dice online. Make your level the best

05.03.2020

The most common form is in the form of a cube, on each side of which the numbers from one to six are depicted. The player, throwing it on a flat surface, sees the result on the top face. Bones are a real mouthpiece of chance, good luck or bad luck.

Accident.
Cubes (bones) have existed for a long time, but the six-sided form that has become traditional was acquired around 2600 BC. e. The ancient Greeks loved to play dice, and in their legends the hero Palamedes, unjustly accused of betrayal by Odysseus, is mentioned as their inventor. According to legend, he invented this game to entertain the soldiers who were besieging Troy, captured thanks to a huge wooden horse. The Romans in the time of Julius Caesar also entertained themselves with a variety of dice games. In Latin, the cube was called datum, which means "given".

Prohibitions.
In the Middle Ages, around the 12th century, dice became very popular in Europe: dice, which you can take with you everywhere, are popular with both warriors and peasants. It is said that there were over six hundred different games! The production of dice becomes a separate profession. King Louis IX (1214-1270), who returned from the crusade, did not approve of gambling and ordered a ban on the production of dice throughout the kingdom. More than the game itself, the authorities were dissatisfied with the unrest associated with it - then they played mainly in taverns and parties often ended in fights and stabbings. But no prohibitions prevented the dice from surviving time and surviving to this day.

Bones with a "charge"!
The outcome of a die roll is always determined by chance, but some cheaters try to change that. By drilling a hole in the die and pouring lead or mercury into it, it is possible to ensure that the roll gives the same result every time. Such a cube is called "charged". Made from various materials, whether it be gold, stone, crystal, bone, dice can have various shapes. Small dice in the shape of a pyramid (tetrahedron) were found in the tombs of the Egyptian pharaohs who built the big pyramids! At various times, bones were made with 8, 10, 12, 20 and even 100 sides. Usually numbers are applied to them, but letters or images can also appear in their place, giving room for imagination.

How to roll the dice.
Dice come in not only different shapes, but also different ways of playing. The rules of some games require the roll to be rolled in a certain way, usually to avoid a calculated roll or to prevent the die from coming to rest in a tilted position. Sometimes a special glass is attached to them to avoid cheating or falling off the gaming table. In the English game of crepe, all three dice must necessarily hit the game table or wall, so as not to allow cheaters to imitate a roll by simply moving the dice, but not turning it.

Randomness and probability.
The dice always gives a random result that cannot be predicted. With one die, the player has just as many chances to roll a 1 as they have a 6 - everything is determined by chance. On the other hand, with two dice, the level of randomness decreases, since the player has more information about the result: for example, with two dice, the number 7 can be obtained in several ways - by rolling 1 and 6, 5 and 2, or 4 and 3 ... But the possibility of getting the number 2 is only one: throwing a 1 twice. Thus, the probability of getting a 7 is higher than getting a 2! It's called probability theory. Many games are associated with this principle, especially cash games.

On the use of dice.
Dice can be a standalone game without other elements. The only thing that practically does not exist is games for a single cube. The rules require at least two (e.g. crepe). To play dice poker you need five dice, a pen and paper. The goal is to fill in combinations similar to the combinations of the card game of the same name, recording points for them in a special table. In addition, the cube is a very popular part for board games, which allows you to move chips or decide the outcome of game battles.

Die is cast.
In 49 BC. e. young Julius Caesar conquered Gaul and returned to Pompeii. But his power was feared by the senators, who decided to disband his army before he returned. The future emperor, having arrived at the borders of the republic, decides to violate the order by crossing it with the army. Before crossing the Rubicon (the river that was the border), he said to his legionnaires "Alea jacta est" ("the die is cast"). This saying has become a catchphrase, the meaning of which is that, like in the game, after some decisions are made, it is no longer possible to back down.

Method of musical composition with loose sound text; as an independent way of composing music took shape in the 20th century. A. means the complete or partial renunciation of the composer's strict control over the musical text, or even the elimination of the very category of the composer-author in the traditional sense. A.'s innovation lies in the correlation of stably established components of a musical text with consciously introduced randomness, arbitrary mobility of musical matter. The concept of A. can refer both to the general layout of the parts of the composition (to the form), and to the structure of its fabric. By E. Denisov, the interaction between the stability and mobility of fabric and form gives 4 main types of combination, three of which - 2nd, 3rd and 4th - are aleatoric: 1. Stable fabric - stable form (usual traditional composition, opus perfectum et absolutum; as, for example, 6 symphonies by Tchaikovsky); 2. Stable fabric - mobile form; according to V. Lutoslavs, “A. forms” (P. Boulez, 3rd sonata for piano, 1957); 3. Mobile fabric - shape stable; or, according to Lutoslavsky, “A. textures” (Lutoslavsky, String Quartet, 1964, Main Movement); 4. Mobile fabric - mobile form; or "A. cage"(with collective improvisation of several performers). These are the nodal points of the method of A., around which there are many different specific types and cases of structures, various degrees of immersion in A.; in addition, metabolas (“modulations”) are also natural - the transition from one type or type to another, also to a stable text or from it.

A. has become widespread since the 1950s, appearing (together with sonorics), in particular, as a reaction to the extreme enslavement of the musical structure in multi-parameter serialism (see: dodecaphony). Meanwhile, the principle of freedom of structure in one way or another has ancient roots. In essence, the sound stream, and not a uniquely structured opus, is folk music. Hence the instability, "non-opus" of folk music, variation, variance and improvisation in it. Unpredictability, improvisation of form are characteristic of the traditional music of India, the peoples of the Far East, and Africa. Therefore, representatives of A. actively and consciously rely on the essential principles of oriental and folk music. Arrow elements also existed in European classical music. For example, among the Viennese classics, who eliminated the principle of the general bass and made the musical text completely stable (symphonies and quartets by I. Haydn), a sharp contrast was the "cadenza" in the form of an instrumental concerto - a virtuoso solo, the part of which the composer did not compose, but provided at the discretion of the performer (element A. form). Comic "aleatoric" methods of composing simple plays (minuets) by combining pieces of music on playing dice (Würfelspiel) are known in the time of Haydn and Mozart (treatise by I.F. Kirnberger "At any time a ready-made composer of polonaises and minuets". Berlin, 1757).


In the XX century. the principle of "individual project" in the form began to suggest the admissibility of textual versions of the work (i.e. A.). In 1907 the American composer C. Ives composed the piano quintet "Hallwe" en (= "All Saints' Eve"), the text of which, when performed in a concert, should be played differently four times in a row. D. cage composed in 1951 “Music of Changes” for the piano, the text of which he compiled by “manipulating accidents” (the words of the composer), using the Chinese “Book of Changes” for this. Classi-

cal example A. - "Piano piece XI" by K. stockhausen, 1957. On a sheet of paper ca. 0.5 sq.m in a random order are 19 musical fragments. The pianist starts with any of them and plays them in random order, following a casual glance; at the end of the previous passage it is written at what tempo and at what volume to play the next one. When it seems to the pianist that he has already played all the fragments in this way, they should be played a second time again in the same random order, but in a brighter sonority. After the second round, the play ends. For greater effect, it is recommended to repeat the aleatoric work in one concert - the listener will see another composition from the same material. Method A. is widely used by modern composers (Boulez, Stockhausen, Lutoslavsky, A. Volkonsky, Denisov, Schnittke and etc.).

A prerequisite for A. in the 20th century. new laws came harmony and the tendencies arising from them to search for new forms that correspond to the new state of musical material and are characteristic of vanguard. Aleatoric texture was completely unthinkable before emancipation dissonance development of atonal music (see: dodecaphony). A supporter of “limited and controlled” A. Lutoslavsky sees in it an undoubted value: “A. opened up new and unexpected vistas for me. First of all - a huge richness of rhythm, unattainable with the help of other techniques. Denisov, justifying the "introduction of random elements into music", claims that it "gives us great freedom in operating with musical matter and allows us to obtain new sound effects<...>, but ideas of mobility can only give good results if<... >if the destructive tendencies hidden in mobility do not destroy the constructiveness necessary for the existence of any form of art.

Some other methods and forms of music intersect with A. First of all, these are: 1. improvisation - performance of a work composed during the game; 2. graphic music, which the performer improvises according to the visual images of the drawing put in front of him (for example, I. Brown, Folio, 1952), translating them into sound images, or according to the musical aleatoric graphics created by the composer from pieces of musical text on a sheet of paper (S. Bussotti, "Passion for the Garden", 1966); 3. happening- improvised (in this sense, aleatoric) action (Stock) with the participation of music with an arbitrary (quasi-) plot (for example, A. Volkonsky's happening "Replica" by the Madrigal ensemble in the 1970/71 season); 4. open forms of music - that is, those whose text is not stably fixed, but is obtained every time in the process of performance. These are types of composition that are not fundamentally closed and allow for an infinite continuation (for example, with each new performance), English. Work in progress. For P. Boulez, one of the stimuli that turned him to an open form was the work of J. Joyce(“Ulysses”) and S. Mallarmé (“Le Livre”). An example of an open composition is Earl Brown's "Available Forms II" for 98 instruments and two conductors (1962). Brown himself points to the connection of his open form with "mobiles" in the visual arts (see: kinetic art) in particular, A. Calder ("Calder Piece" for 4 drummers and Calder's mobile, 1965). Finally, the “Gesamtkunst” action is permeated with aleatoric principles (see: Gezamtkunstwerk). 5. Multimedia whose specificity is synchronization installations several arts (for example: a concert + an exhibition of painting and sculpture + an evening of poetry in any combination of art forms, etc.). Thus, the essence of A. is to reconcile the traditionally established artistic order and the refreshing ferment of unpredictability, randomness - a tendency characteristic of artistic culture of the XX century. in general and non-classical aesthetics.

Lit .: Denisov E.V. Stable and mobile elements of the musical form and their interaction// Theoretical problems of musical forms and genres. M., 1971; Kohoutek C. Composition technique in the music of the XX century. M., 1976; Lutoslavsky V. Articles, be-

gray hair, memories. M., 1995; Boulez P. Alea// Darmstädter Beiträge zur Neuen Musik. L, Mainz, 1958; Boulez R. Zu meiner III Sonate// Ibid, III. 1960; Schaffer B. Nowa muzyka (1958). Krakow, 1969; Schaffer B. Malý informátor muzyki XX wieku (1958). Krakow, 1975; Stockhausen K. Musik und Grafik (1960) // Texte, Bd.l, Köln, 1963; Böhmer K. Theorie der offenen Form in der Musik. Darmstadt, 1967.

Dice have been used by man for thousands of years.

In the 21st century, new technologies allow you to roll the die at any convenient time, and if you have Internet access, in a convenient place. The dice is always with you at home or on the road.

The dice generator allows you to roll online from 1 to 4 dice.

Roll the die online honestly

When using real dice, sleight of hand or specially made dice with an advantage to one of the sides can be used. For example, you can spin the cube along one of the axes, and then the probability distribution will change. A feature of our virtual cubes is the use of a software pseudo-random number generator. This allows you to provide a truly random variant of this or that result.

And if you bookmark this page, then your online dice will not be lost anywhere and will always be at hand at the right time!

Some people have adapted to use online dice for divination or making forecasts and horoscopes.

Cheerful mood, good day and good luck!

Written by designer Tyler Sigman, on "Gamasutra". I affectionately refer to it as the “hair in the nostrils of an orc” article, but it covers the basics of probabilities in games pretty well.

This week's theme

Until today, almost everything we've talked about has been deterministic, and last week we took a closer look at transitive mechanics and broke it down in as much detail as I can explain it. But until now we have not paid attention to a huge aspect of many games, namely the non-deterministic aspects, in other words - randomness. Understanding the nature of randomness is very important for game designers because we create systems that affect the player's experience in a given game, so we need to know how these systems work. If there is randomness in the system, you need to understand nature this randomness and how to change it to get the results we want.

Dice

Let's start with something simple: rolling dice. When most people think of dice, they think of a six-sided die known as a d6. But most gamers have seen many other dice: four-sided (d4), eight-sided (d8), twelve-sided (d12), twenty-sided (d20) ... and if you real geek, you might have some 30-sided or 100-sided dice somewhere. If you're not familiar with this terminology, the "d" means a die, and the number after it is how many faces it has. If a before“d” stands for a number, it stands for amount dice when thrown. For example, in Monopoly, you roll 2d6.

So, in this case, the phrase “dice” is a conventional designation. There are a huge number of other random number generators that do not have the shape of a plastic block, but perform the same function of generating a random number from 1 to n. An ordinary coin can also be thought of as a dihedral d2 die. I saw two designs of a seven-sided die: one of them looked like a dice, and the second looked more like a seven-sided wooden pencil. A tetrahedral dreidel (also known as a titotum) is an analogue of a tetrahedral bone. The spinning arrow playing field in the game “Chutes & Ladders”, where the result can be from 1 to 6, corresponds to a six-sided die. The random number generator in the computer can create any number from 1 to 19 if the designer gives such a command, although the computer does not have a 19-sided dice (in general, I will talk more about the probability of numbers falling on the computer at next week). Although all of these items look different, they are actually equivalent: you have an equal chance of getting one of several outcomes.

Dice have some interesting properties that we need to know about. First, the probability of any of the faces coming up is the same (I'm assuming you're rolling the right dice, not the wrong geometry). So if you want to know mean roll (also known among the probabilists as the “mathematical expectation”), sum the values ​​of all the edges and divide this sum by amount faces. The average value of a roll for a standard six-sided die is 1+2+3+4+5+6 = 21, divided by the number of faces (6) and we get the average value of 21/6 = 3.5. This is a special case because we assume that all outcomes are equally likely.

What if you have special dice? For example, I saw a game with a six-sided die with special stickers on the faces: 1, 1, 1, 2, 2, 3, so it behaves like a strange three-sided die, which is more likely to roll the number 1 than 2, and 2 than 3. What is the average roll value for this die? So 1+1+1+2+2+3 = 10 divided by 6 equals 5/3 or about 1.66. So if you have this particular dice and the players roll three dice and then add up the results, you know that the approximate sum of their rolls will be about 5, and you can balance the game based on that assumption.

Dice and independence

As I already said, we proceed from the assumption that the dropout of each face is equally probable. It does not depend on how many dice you throw. Every roll of a dice regardless, which means that previous rolls do not affect the results of subsequent rolls. With a sufficient number of tests, you will definitely notice"series" of numbers, such as rolling mostly higher or lower values, or other features, and we'll talk about that later, but that doesn't mean the dice are "hot" or "cold." If you roll a standard six-sided die and the number 6 comes up twice in a row, the probability that the next roll will result in a 6 is also 1/6. The probability is not increased by the fact that the cube is “warmed up”. The probability does not decrease, because the number 6 has already fallen out twice in a row, which means that now another face will fall out. (Of course, if you roll a die twenty times and the number 6 comes up each time, the chance that the number 6 will come up the twenty-first time is pretty high ... because it might mean that you have the wrong die!) But if you have the right die, the probability of falling out of each of the faces is the same, regardless of the results of other rolls. You can also imagine that each time we change the dice, so if the number 6 rolled twice in a row, remove the "hot" dice from the game and replace it with a new six-sided die. I apologize if any of you already knew about this, but I needed to clarify this before moving on.

How to make dice roll more or less random

Let's talk about how to get different results on different dice. If you roll the die only once or multiple times, the game will feel more random if the die has more edges. The more times you roll a dice, or the more dice you roll, the more the results approach the average. For example, if you roll 1d6+4 (i.e. a standard six-sided die once and add 4 to the result), the average will be a number between 5 and 10. If you roll 5d2, the average will also be a number between 5 and 10. But when throwing a six-sided dice, the probability of getting the numbers 5, 8 or 10 is the same. The result of a 5d2 roll will be mostly the numbers 7 and 8, less often other numbers. The same series, even the same average (7.5 in both cases), but the nature of the randomness is different.

Wait a minute. Didn't I just say that dice don't heat up or cool down? And now I'm saying that if you roll a lot of dice, the results of the rolls are closer to the average? Why?

Let me explain. If you are throwing one dice, the probability of falling out of each of the faces is the same. This means that if you roll a lot of dice, over time, each face will come up about the same number of times. The more dice you roll, the more the total result will approach the average. It's not because the rolled number "causes" another number to roll that hasn't yet come up. Because a small streak of 6s (or 20s or whatever) doesn't end up being a big deal if you roll the dice ten thousand more times and it mostly comes up in the middle...maybe now you'll have a few numbers with a high value, but maybe later a few numbers with a low value and over time they will approach the average value. Not because previous rolls affect the dice (seriously, the dice is made of plastic, she doesn't have the brains to think "oh, it's been a long time since a 2 came up"), but because that's what usually happens with a lot of dice rolls. A small series of repeating numbers will be almost invisible in a large number of results.

Thus, it is fairly easy to calculate for one random roll of a die, at least as far as calculating the average value of the roll. There are also ways to calculate "how random" something is, a way to say that the results of a 1d6+4 roll will be "more random" than a 5d2, for a 5d2 the distribution of the roll results will be more uniform, usually you calculate the standard deviation for this, and the more value, the more random the results will be, but this requires more calculations than I would like to give today (I will explain this topic later). The only thing I ask you to know is that as a general rule, the fewer dice rolled, the more random. And one more addition on this topic: the more sides the die has, the more randomness, since you have more options.

How to Calculate Probability Using Counting

You may have a question: how can we calculate the exact probability of a particular result coming up? This is actually quite important for many games, because if you roll a die, there is likely to be some optimal outcome initially. The answer is: we need to calculate two values. First, calculate the maximum number of outcomes when throwing a die (regardless of what the outcome will be). Then count the number of favorable outcomes. By dividing the second value by the first, you get the desired probability. To get a percentage, multiply the result by 100.

Examples:

Here is a very simple example. You want to roll a 4 or higher and roll a six-sided die once. The maximum number of outcomes is 6 (1, 2, 3, 4, 5, 6). Of these, 3 outcomes (4, 5, 6) are favorable. So, to calculate the probability, we divide 3 by 6 and get 0.5 or 50%.

Here's an example that's a little more complicated. You want an even number on a 2d6 roll. The maximum number of outcomes is 36 (6 for each dice, and since one dice does not affect the other, we multiply 6 results by 6 and get 36). The difficulty with this type of question is that it is easy to count twice. For example, there are actually two possible outcomes of a 3 on a 2d6 roll: 1+2 and 2+1. They look the same, but the difference is what number is displayed on the first dice and what is on the second. You can also imagine that the dice are of different colors, so for example in this case one dice is red and the other is blue. Then count the number of options for getting an even number: 2 (1+1), 4 (1+3), 4 (2+2), 4 (3+1), 6 (1+5), 6 (2+4), 6 (3+3), 6 (4+2), 6 (5+1), 8 (2+6), 8 (3+5), 8 (4+4), 8 (5+3), 8 (6+2), 10 (4+6), 10 (5+5), 10 (6+4), 12 (6+6). It turns out that there are 18 options for a favorable outcome out of 36, as in the previous case, the probability will be 0.5 or 50%. Perhaps unexpected, but quite accurate.

Monte Carlo simulation

What if you have too many dice for this calculation? For example, you want to know what is the probability of rolling a total of 15 or more on a roll of 8d6. There are MANY different individual scores for eight dice and it would take a very long time to calculate them by hand. Even if we find some good solution to group different series of dice rolls, it will still take a very long time to count. In this case, the easiest way to calculate the probability is not to calculate manually, but to use a computer. There are two ways to calculate probability on a computer.

The first way can get the exact answer, but it involves a bit of programming or scripting. In essence, the computer will go through each possibility, evaluate and count the total number of iterations and the number of iterations that correspond to the desired result, and then provide answers. Your code might look something like this:

int wincount=0, totalcount=0;

for (int i=1; i<=6; i++) {

for (int j=1; j<=6; j++) {

for (int k=1; k<=6; k++) {

… // insert more loops here

if (i+j+k+… >= 15) (

float probability = wincount/totalcount;

If you're not a programmer and you just want an inaccurate but approximate answer, you can simulate this situation in Excel, where you roll 8d6 a few thousand times and get the answer. To roll 1d6 in Excel, use the following formula:

FLOOR(RAND()*6)+1

There is a name for the situation when you don't know the answer and just try many times - Monte Carlo simulation, and it's a great solution to fall back on when you're trying to calculate a probability and it's too complicated. The great thing is that in this case, we don't need to understand how the math works, and we know that the answer will be "pretty good" because, as we already know, the more rolls, the more the result approaches the average value.

How to combine independent trials

If you ask about multiple repeated but independent trials, then the outcome of one roll does not affect the outcome of other rolls. There is another simpler explanation for this situation.

How to distinguish between something dependent and independent? In principle, if you can isolate each roll of a die (or series of rolls) as a separate event, then it is independent. For example, if we want to roll a total of 15 by rolling 8d6, this case cannot be divided into several independent rolls of dice. Since you are calculating the sum of the values ​​of all the dice for the result, the result that is rolled on one dice affects the results that should be rolled on other dice, because only by summing all the values ​​will you get the desired result.

Here's an example of independent rolls: you're playing a game of dice, and you roll six-sided dice several times. To stay in the game, you must roll a 2 or higher on your first roll. For the second roll, 3 or higher. Third requires 4 or more, fourth requires 5 or more, fifth requires 6. If all five rolls are successful, you win. In this case, all throws are independent. Yes, if one roll fails, it will affect the outcome of the entire game, but one roll does not affect another roll. For example, if your second roll of the dice is very successful, this does not affect the likelihood that the next rolls will be equally successful. Therefore, we can consider the probability of each roll of the dice separately.

If you have separate, independent probabilities and want to know what is the probability that all events will come, you determine each individual probability and multiply them. Another way: if you use the conjunction “and” to describe several conditions (for example, what is the probability of some random event occurring and some other independent random event?), calculate the individual probabilities and multiply them.

It doesn't matter what you think never do not sum the independent probabilities. This is a common mistake. To understand why this is wrong, imagine a situation where you flip a coin 50/50 and you want to know what is the probability of getting heads twice in a row. Each side has a 50% chance of coming up, so if you add the two probabilities, you get a 100% chance of coming up heads, but we know that's not true because two consecutive tails could come up. If instead you multiply these two probabilities, you get 50% * 50% = 25%, which is the correct answer for calculating the probability of getting heads twice in a row.

Example

Let's go back to the six-sided dice game, where you need to first roll a number higher than 2, then higher than 3, and so on. up to 6. What are the chances that in a given series of 5 throws, all outcomes will be favorable?

As mentioned above, these are independent trials, so we calculate the probability for each individual roll and then multiply them. The probability that the outcome of the first toss will be favorable is 5/6. The second - 4/6. Third - 3/6. The fourth - 2/6, the fifth - 1/6. Multiplying all these results, we get about 1.5%… So, winning this game is quite rare, so if you add this element to your game, you will need a pretty big jackpot.

Negation

Here is another useful hint: sometimes it is difficult to calculate the probability that an event will occur, but it is easier to determine what are the chances that an event will occur. will not come.

For example, suppose we have another game and you roll 6d6, and if at least once rolls 6, you win. What is the probability of winning?

In this case, there are many options to consider. Perhaps one number 6 will fall out, i.e. one of the dice will roll a 6 and the others will roll a 1 to 5, and there are 6 options for which of the dice will roll a 6. Then you can roll a 6 on two dice, or three, or even more, and each time we need to do a separate calculation, so it's easy to get confused.

But there is another way to solve this problem, let's look at it from the other side. You lose if none the number 6 will not fall out of the dice. In this case, we have six independent trials, the probability of each of them is 5/6 (any number other than 6 can fall on the dice). Multiply them and you get about 33%. Thus, the probability of losing is 1 to 3.

Therefore, the probability of winning is 67% (or 2 to 3).

From this example it is obvious that if you are calculating the probability that an event will not occur, subtract the result from 100%. If the probability of winning is 67%, then the probability lose — 100% minus 67%, or 33%. And vice versa. If it is difficult to calculate one probability, but easy to calculate the opposite, calculate the opposite, and then subtract from 100%.

Connecting conditions for one independent test

I said a little earlier that you should never sum probabilities in independent trials. Are there any cases where can sum the probabilities? Yes, in one particular situation.

If you want to calculate the probability of multiple, unrelated, favorable outcomes on the same trial, sum the probabilities of each favorable outcome. For example, the probability of rolling a 4, 5, or 6 on 1d6 is sum the probability of rolling a 4, the probability of rolling a 5, and the probability of rolling a 6. You can also think of this situation as follows: if you use the conjunction “or” in a question about probability (for example, what is the probability of or different outcome of one random event?), calculate the individual probabilities and sum them up.

Note that when you sum all possible outcomes game, the sum of all probabilities must be equal to 100%. If the sum is not equal to 100%, your calculation was made incorrectly. This is a good way to double check your calculations. For example, you analyzed the probability of getting all combinations in poker, if you add up all the results, you should get exactly 100% (or at least a value quite close to 100%, if you use a calculator, you may have a small rounding error , but if you add up the exact numbers by hand, everything should add up). If the sum does not converge, then most likely you did not take into account some combinations, or you calculated the probabilities of some combinations incorrectly, and then you need to double-check your calculations.

Unequal probabilities

Until now, we have assumed that each face of the die falls out at the same frequency, because this is how the die works. But sometimes you are faced with a situation where different outcomes are possible and they various drop chances. For example, in one of the expansions of the card game "Nuclear War" there is a playing field with an arrow, which determines the result of a missile launch: it basically deals normal damage, more or less damage, but sometimes the damage is doubled or tripled, or the rocket explodes on the launch pad and harms you, or another event occurs. Unlike the arrow board in "Chutes & Ladders" or "A Game of Life", the results of the board in "Nuclear War" are unequal. Some sections of the playing field are larger and the arrow stops on them much more often, while other sections are very small and the arrow stops on them rarely.

So, at first glance, the bone looks something like this: 1, 1, 1, 2, 2, 3; we already talked about it, it is something like a weighted 1d3, therefore, we need to divide all these sections into equal parts, find the smallest unit of measure, which is a multiple of it, and then represent the situation as d522 (or some other ), where the set of dice faces will display the same situation, but with a larger number of outcomes. And this is one way to solve the problem, and it is technically feasible, but there is an easier way.

Let's go back to our standard six-sided dice. We said that in order to calculate the average value of a throw for a normal dice, you need to sum the values ​​​​on all faces and divide them by the number of faces, but how exactly is the calculation going on? You can express it differently. For a six-sided dice, the probability of each face coming up is exactly 1/6. Now we multiply Exodus each edge on probability this outcome (in this case, 1/6 for each face), then sum up the resulting values. So summing (1*1/6) + (2*1/6) + (3*1/6) + (4*1/6) + (5*1/6) + (6*1/6 ), we get the same result (3.5) as in the calculation above. In fact, we calculate this every time: we multiply each outcome by the probability of that outcome.

Can we do the same calculation for the arrow on the playing field in the game "Nuclear War"? Of course we can. And if we sum up all the found results, we get the average value. All we have to do is calculate the probability of each outcome for the arrow on the playing field and multiply by the outcome.

Another example

This method of calculating the average, by multiplying each outcome by its individual probability, is also appropriate if the outcomes are equally likely but have different advantages, such as if you roll a die and win more on some sides than others. For example, let's take a game that happens in a casino: you bet and roll 2d6. If three low value numbers (2, 3, 4) or four high value numbers (9, 10, 11, 12) come up, you will win an amount equal to your bet. The numbers with the lowest and highest value are special: if 2 or 12 rolls, you win twice as much than your bid. If any other number comes up (5, 6, 7, 8), you will lose your bet. This is a pretty simple game. But what is the probability of winning?

Let's start by counting how many times you can win:

  • The maximum number of outcomes on a 2d6 roll is 36. What is the number of favorable outcomes?
  • There is 1 option that two will fall out and 1 option that twelve will fall out.
  • There are 2 options for rolling three and eleven.
  • There are 3 options for rolling four and 3 options for rolling ten.
  • There are 4 options for nine to come up.
  • Summing up all the options, we get the number of favorable outcomes 16 out of 36.

Thus, under normal conditions, you will win 16 times out of 36 possible... the probability of winning is slightly less than 50%.

But in two cases out of those 16, you will win twice as much, i.e. it's like winning twice! If you play this game 36 times, betting $1 each time, and each of all possible outcomes comes up once, you will win a total of $18 (you actually win 16 times, but two of those times will count as two win). If you play 36 times and win $18, doesn't that mean it's an even chance?

Take your time. If you count the number of times you can lose, you get 20, not 18. If you play 36 times, betting $1 each time, you'll win a total of $18 with all the odds rolled... but you'll lose the total the amount of $20 for all 20 bad outcomes! As a result, you will be slightly behind: you lose an average of $2 net for every 36 games played (you can also say that you lose an average of $1/18 a day). Now you see how easy it is to make a mistake in this case and calculate the probability incorrectly!

Permutation

So far, we have assumed that the order in which the numbers are thrown does not matter when rolling the dice. A 2+4 roll is the same as a 4+2 roll. In most cases, we manually count the number of favorable outcomes, but sometimes this method is impractical and it is better to use a mathematical formula.

An example of this situation is from the dice game “Farkle”. For each new round, you roll 6d6. If you are lucky and all possible outcomes of 1-2-3-4-5-6 (Straight) come up, you will get a big bonus. What is the probability that this will happen? In this case, there are many options for the loss of this combination!

The solution is as follows: one of the dice (and only one) must roll the number 1! How many ways to get the number 1 on one dice? Six, since there are 6 dice, and any one of them can land the number 1. Accordingly, take one dice and set it aside. Now, the number 2 should fall on one of the remaining dice. There are five options for this. Take another dice and set it aside. Then it follows that four of the remaining dice may roll a 3, three of the remaining dice may roll a 4, two of the remaining dice may roll a 5, and you end up with one die that must roll a 6 (in the latter case, there is only one dice and there is no choice). To calculate the number of favorable outcomes for a straight combination to come up, we multiply all the different, independent options: 6x5x4x3x2x1 = 720 - it looks like there are quite a lot of options for this combination to come up.

To calculate the probability of getting a straight combination, we need to divide 720 by the number of all possible outcomes for rolling 6d6. What is the number of all possible outcomes? Each die can land 6 faces, so we multiply 6x6x6x6x6x6 = 46656 (much higher number!). We divide 720/46656 and we get a probability equal to approximately 1.5%. If you were designing this game, it would be useful for you to know this so that you can create an appropriate scoring system. Now we understand why in the game "Farkle" you get such a big bonus if you get a combination of "straight", because this situation is quite rare!

The result is also interesting for another reason. The example shows how rarely a result corresponding to the probability actually falls out in a short period. Of course, if we rolled several thousand dice, different sides of the dice would come up quite often. But when we roll only six dice, almost never it does not happen that each of the faces falls out! Proceeding from this, it becomes clear that it is foolish to expect that another face will fall out now, which has not yet fallen out “because we haven’t dropped the number 6 for a long time, which means it will fall out now.”

Look, your random number generator is broken...

This brings us to a common misconception about probability: the assumption that all outcomes come up with the same frequency. over a short period of time, which is actually not the case. If we roll the dice several times, the frequency of each of the faces will not be the same.

If you have ever worked on an online game with some kind of random number generator before, you have most likely encountered a situation where a player writes to technical support to say that your random number generator is broken and does not show random numbers, and he came to this conclusion because he just killed 4 monsters in a row and received 4 exactly the same rewards, and these rewards should only drop 10% of the time, so this Almost never shouldn't take place, which means it obviously that your random number generator is broken.

You are doing math. 1/10*1/10*1/10*1/10 equals 1 in 10,000, which means it's pretty rare. And that's what the player is trying to tell you. Is there a problem in this case?

Everything depends on the circumstances. How many players are on your server now? Suppose you have a fairly popular game and 100,000 people play it every day. How many players will kill four monsters in a row? Anything is possible, several times a day, but let's assume that half of them are just trading different items at auctions or chatting on RP servers, or doing other game activities, so only half of them are actually hunting monsters. What is the probability that someone will the same reward drop out? In this situation, you can expect that the same reward can drop several times a day, at least!

By the way, that's why it seems like every few weeks at least somebody wins the lottery, even if that someone never you or your friends do not come. If enough people play each week, chances are there will be at least one lucky... but if you you play the lottery, you are less likely to win a job at Infinity Ward.

Maps and addiction

We have discussed independent events, such as throwing a die, and now we know many powerful tools for analyzing randomness in many games. The probability calculation is a little more complicated when it comes to drawing cards from the deck, because each card we draw affects the remaining cards in the deck. If you have a standard deck of 52 cards and you draw 10 of hearts, for example, and you want to know the probability that the next card will be the same suit, the probability has changed because you have already removed one heart card from the deck. Each card you remove changes the probability of the next card in the deck. Since in this case the previous event affects the next one, we call this probability dependent.

Please note that when I say "cards" I mean any game mechanics in which there is a set of objects and you remove one of the objects without replacing it, a “deck of cards” in this case is analogous to a bag of chips from which you remove one chip and do not replace it, or an urn from which you remove colored marbles (actually I've never seen a game that had an urn with colored marbles taken out of it, but it seems that probability teachers prefer this example for some reason).

Dependency properties

I'd like to clarify that when it comes to cards, I'm assuming you draw cards, look at them, and remove them from the deck. Each of these actions is an important property.

If I had a deck of, say, six cards numbered 1 to 6, and I shuffled them and drew one card and then shuffled all six cards again, that would be the same as rolling a six-sided die; one result does not affect the next. Only if I draw cards and don't replace them will the result of drawing a card with the number 1 increase the probability that the next time I draw a card with the number 6 (the probability will increase until I eventually draw this card or until I shuffle the cards).

The fact that we we look on cards is also important. If I take a card out of the deck and don't look at it, I don't have any additional information and the probability doesn't actually change. This may sound illogical. How can simply flipping a card magically change the odds? But it is possible, because you can calculate the probability for unknown items only from the fact that you you know. For example, if you shuffle a standard deck of cards, reveal 51 cards and none of them are queen of clubs, you will know with 100% certainty that the remaining card is a queen of clubs. If you shuffle a standard deck of cards and draw 51 cards, despite on them, then the probability that the remaining card is the queen of clubs will still be 1/52. As you open each card, you get more information.

Calculating the probability for dependent events follows the same principles as for independent events, except that it's a bit more complicated, as the probabilities change when you reveal the cards. Thus, you need to multiply many different values, instead of multiplying the same value. In fact, this means that we need to combine all the calculations that we did into one combination.

Example

You shuffle a standard deck of 52 cards and draw two cards. What is the probability that you will take out a pair? There are several ways to calculate this probability, but perhaps the simplest is as follows: what is the probability that if you draw one card, you will not be able to draw a pair? This probability is zero, so it doesn't really matter which first card you draw, as long as it matches the second. No matter which card we draw first, we still have a chance to draw a pair, so the probability that we can draw a pair after drawing the first card is 100%.

What is the probability that the second card will match the first? There are 51 cards left in the deck and 3 of them match the first card (actually it would have been 4 out of 52, but you already removed one of the matching cards when you drew the first card!), so the probability is 1/17. (So ​​the next time the guy across the table playing Texas Hold'em says, "Cool, another pair? I'm lucky today," you'll know there's a pretty high chance he's bluffing.)

What if we add two jokers and now we have 54 cards in the deck and we want to know what is the probability of drawing a pair? The first card may be the Joker, and then the deck will only contain one card, not three, which will match. How to find the probability in this case? We divide the probabilities and multiply each possibility.

Our first card could be a joker or some other card. The probability of drawing a joker is 2/54, the probability of drawing some other card is 52/54.

If the first card is a joker (2/54), then the probability that the second card will match the first is 1/53. Multiplying the values ​​(we can multiply them because they are separate events and we want to both events happened) and we get 1/1431 - less than one tenth of a percent.

If you draw some other card first (52/54), the probability of matching the second card is 3/53. We multiply the values ​​​​and get 78/1431 (a little more than 5.5%).

What do we do with these two results? They don't intersect and we want to know the probability each of them, so we sum up the values! We get the final result 79/1431 (still about 5.5%).

If we wanted to be sure of the accuracy of the answer, we could calculate the probability of all other possible outcomes: drawing a joker and not matching the second card, or drawing some other card and not matching the second card, and summing them all with the probability of winning, we would received exactly 100%. I won't give the math here, but you can try the math to double check.

The Monty Hall Paradox

This brings us to a rather famous paradox that often confuses many, the Monty Hall paradox. The paradox is named after Monty Hall, the host of the TV show Let's Make a Deal. If you've never seen this show, it was the opposite of the TV show "The Price Is Right". On “The Price Is Right,” the host (formerly Bob Barker, now it's…Drew Carey? Anyway…) is your friend. He wants for you to win money or cool prizes. It tries to give you every opportunity to win, as long as you can guess how much the sponsored items are actually worth.

Monty Hall behaved differently. He was like the evil twin of Bob Barker. His goal was to make you look like an idiot on national television. If you were on the show, he was your opponent, you played against him and the odds were in his favor. Maybe I'm being harsh, but when the chance of being picked as an opponent seems to be directly proportional to whether or not you're wearing a ridiculous costume, I come to similar conclusions.

But one of the show's most famous memes was this: there were three doors in front of you, and they were called Door Number 1, Door Number 2, and Door Number 3. You could choose any one door... for free! Behind one of these doors, there was a magnificent prize, for example, a new car. There were no prizes behind the other doors, these two doors were of no value. Their goal was to humiliate you and so it's not like there was nothing behind them at all, there was something behind them that looked stupid, like a goat behind them or a huge tube of toothpaste, or something ... something, what exactly was not new car.

You chose one of the doors and Monty was about to open it to let you know whether you won or not... but wait, before we know let's look at one of those the door you not chosen. Since Monty knows which door the prize is behind, and there is only one prize and two doors that you have not chosen, no matter what, he can always open a door that does not have a prize behind it. “Do you choose Door number 3? Then let's open Door 1 to show that there was no prize behind it." And now, out of generosity, he's offering you the chance to trade your chosen Door #3 for the one behind Door #2. This is where the question of probability comes into play: does being able to choose a different door increase or decrease your chance of winning, or does it stay the same? What do you think?

Correct answer: the ability to choose another door increases probability of winning from 1/3 to 2/3. This is illogical. If you haven't encountered this paradox before, chances are you're thinking: wait, opening one door, we magically changed the probability? But as we saw in the map example above, this is exactly what happens when we get more information. It's obvious that the probability of winning the first time you pick is 1/3, and I guess everyone will agree on that. When one door opens, it does not change the probability of winning for the first choice at all, the probability is still 1/3, but this means that the probability that another door correct is now 2/3.

Let's look at this example from the other side. You choose a door. The probability of winning is 1/3. I suggest you change two other doors, which is what Monty Hall actually proposes to do. Of course, he opens one of the doors to show that there is no prize behind it, but he always can do so, so it doesn't really change anything. Of course, you will want to choose a different door!

If you don't quite understand this issue and need a more convincing explanation, click on this link to go to a great little Flash application that will allow you to explore this paradox in more detail. You can start with about 10 doors and then gradually move up to a game with three doors; there is also a simulator where you can choose any number of doors from 3 to 50 and play or run several thousand simulations and see how many times you would win if you played.

A note from a teacher of higher mathematics and a specialist in game balance Maxim Soldatov, which, of course, Schreiber did not have, but without which it is rather difficult to understand this magical transformation:

Choose a door, one of three, the probability of "winning" 1/3. Now you have 2 strategies: change the choice after opening the wrong door or not. If you do not change your choice, then the probability will remain 1/3, since the choice is only at the first stage, and you must immediately guess, but if you change, then you can win if you choose the wrong door first (then they open another wrong one, will remain true, you change the decision just take it)
The probability of choosing the wrong door at the beginning is 2/3, so it turns out that by changing your decision you make the probability of winning 2 times more

Revisiting the Monty Hall Paradox

As for the show itself, Monty Hall knew this, because even if his opponents weren't good at math, he understands her well. Here's what he did to change the game a bit. If you chose the door behind which the prize was, the probability of which is 1/3, it always offered you the option to choose another door. Because you chose a car and then you change it to a goat and you look pretty stupid, which is exactly what he needs, because he is kind of an evil guy. But if you choose the door behind which there will be no prize, only half in such cases he will prompt you to choose another door, and in other cases he will simply show you your new goat and you will leave the stage. Let's analyze this new game where Monty Hall can choose offer you a chance to choose another door or not.

Suppose he follows this algorithm: if you choose a door with a prize, he always offers you the opportunity to choose another door, otherwise the probability that he will offer you a different door or give you a goat is 50/50. What is the probability of your winning?

In one of the three options, you immediately choose the door behind which the prize is located, and the host invites you to choose another door.

Of the remaining two options out of three (you initially choose a door with no prize), half the time the host will ask you to choose a different door, and the other half of the time it won't. Half of 2/3 is 1/3, i.e. in one case out of three you will get a goat, in one case out of three you will choose the wrong door and the host will ask you to choose another one and in one case out of three you will choose the right door and he will prompt you to choose another door.

If the host suggests choosing a different door, we already know that one of the three cases when he gives us a goat and we leave did not happen. This is useful information because it means that our chances of winning have changed. Two out of three times we have a choice, in one case it means we guessed right, and in the other case it means we guessed wrong, so if we were offered a choice at all, that means the probability of our winning is 50 /50, and there is no mathematical benefits, stay with your choice or choose another door.

Like poker, it is now a psychological game, not a mathematical one. Monty offered you a choice because he thinks you're a dumbass who doesn't know that choosing a different door is the "right" decision and that you will stick with your choice because psychologically the situation is when you choose a car, and then lost it, harder? Or does he think you're smart and choose another door, and he offers you that chance because he knows you guessed right the first time and that you'll be hooked and trapped? Or maybe he is uncharacteristically kind to himself and pushes you to do something in your personal interest because he hasn't donated a car for a long time and his producers tell him that the audience is getting bored and he better give a big prize soon. so that the ratings do not fall?

Thus, Monty manages to offer a choice (sometimes) and the overall probability of winning remains 1/3. Remember that the probability that you will lose immediately is 1/3. There is a 1/3 chance that you will guess right right away, and 50% of those times you will win (1/3 x 1/2 = 1/6). The probability that you guess wrong at first, but then have a chance to choose another door is 1/3, and in 50% of these cases you will win (also 1/6). Add up two independent winning possibilities and you get a probability of 1/3, so whether you stay on your choice or choose another door, the total probability of your winning throughout the game is 1/3... the probability does not get greater than in a situation where you would have guessed the door and the host would have shown you what is behind this door, without the ability to choose another door! So the point of offering the option to choose a different door is not to change the probability, but to make the decision process more fun to watch on TV.

By the way, this is one of the very reasons why poker can be so interesting: in most formats between rounds, when bets are made (for example, the flop, turn and river in Texas Hold'em), the cards are gradually revealed, and if at the beginning of the game you have one the probability of winning, then after each round of betting, when more cards are open, this probability changes.

Boy and girl paradox

This brings us to another well-known paradox that tends to puzzle everyone, the boy-girl paradox. The only thing I'm writing about today that isn't directly related to games (although I'm guessing that just means that I should push you to create relevant game mechanics). This is more of a puzzle, but an interesting one, and in order to solve it, you need to understand the conditional probability that we talked about above.

Task: I have a friend with two children, at least one the child is a girl. What is the probability that the second child too girl? Let's assume that in any family the chance of having a girl or a boy is 50/50 and this is true for every child (in fact, some men have more sperm in the sperm with an X chromosome or a Y chromosome, so the probability changes slightly if you know that one child is a girl, the probability of having a girl is slightly higher, in addition there are other conditions, for example, hermaphroditism, but for solving this problem, we will not take this into account and assume that the birth of a child is an independent event and the probability of having a boy or girls are the same).

Since we're talking about a 1/2 chance, we intuitively expect the answer to be probably 1/2 or 1/4, or some other round number that's a multiple of 2. But the answer is: 1/3 . Wait why?

The difficulty in this case is that the information that we have reduces the number of possibilities. Suppose the parents are Sesame Street fans and, regardless of whether the child was born a boy or a girl, named their children A and B. Under normal circumstances, there are four equally likely possibilities: A and B are two boys, A and B are two girls, A is a boy and B is a girl, A is a girl, and B is a boy. Since we know that at least one the child is a girl, we can rule out the possibility that A and B are two boys, leaving us with three (still equally likely) possibilities. If all possibilities are equally likely and there are three of them, we know that the probability of each of them is 1/3. Only in one of these three options are both children two girls, so the answer is 1/3.

And again about the paradox of a boy and a girl

The solution to the problem becomes even more illogical. Imagine that I tell you that my friend has two children and one child - girl born on tuesday. Suppose that under normal conditions the probability of having a child on one of the seven days of the week is the same. What is the probability that the second child is also a girl? You might think that the answer would still be 1/3; What is the significance of Tuesday? But in this case, intuition fails us. Answer: 13/27 which is not just not intuitive, it is very strange. What's the matter in this case?

In fact, Tuesday changes the probability because we don't know which baby was born on Tuesday or possibly two children were born on a Tuesday. In this case, we use the same logic as above, we count all possible combinations when at least one child is a girl who was born on Tuesday. As in the previous example, suppose the children are named A and B, the combinations are as follows:

  • A is a girl who was born on Tuesday, B is a boy (in this situation there are 7 possibilities, one for each day of the week when a boy could be born).
  • B is a girl who was born on Tuesday, A is a boy (also 7 possibilities).
  • A is a girl who was born on Tuesday, B is a girl who was born on another day of the week (6 possibilities).
  • B is a girl who was born on Tuesday, A is a girl who was not born on Tuesday (also 6 probabilities).
  • A and B are two girls who were born on Tuesday (1 possibility, you need to pay attention to this so as not to count twice).

We sum up and get 27 different equally possible combinations of the birth of children and days with at least one possibility of a girl being born on Tuesday. Of these, 13 possibilities are when two girls are born. It also looks completely illogical, and it seems that this task was created only to cause a headache. If you're still puzzled by this example, game theorist Jesper Juhl has a good explanation of the matter on his website.

If you are currently working on a game...

If there is randomness in the game you are designing, this is a great opportunity to analyze it. Select any element you want to analyze. First ask yourself what is the probability for this element according to your expectations, what it should be, in your opinion, in the context of the game. For example, if you're making an RPG and you're thinking about how likely it should be for a player to be able to defeat a monster in combat, ask yourself what percentage of wins feels right to you. Usually when playing console RPGs, players get very frustrated when they lose, so it's better that they don't lose often... maybe 10% of the time or less? If you're an RPG designer, you probably know better than I do, but you need to have a basic idea of ​​what the probability should be.

Then ask yourself if this is something dependent(like cards) or independent(like dice). Discuss all possible outcomes and their probabilities. Make sure that the sum of all probabilities is 100%. Finally, of course, compare your results with your expectations. Whether the dice is rolled or the cards are drawn the way you intended or you see that you need to adjust the values. And of course if you find what needs to be adjusted, you can use the same calculations to determine how much to adjust something!

Homework

Your “homework” this week will help you hone your probability skills. Here are two dice games and a card game that you will analyze using probability, as well as a strange game mechanic that I once developed that you will test the Monte Carlo method on.

Game #1 - Dragon Bones

This is a dice game that my colleagues and I once came up with (thanks to Jeb Havens and Jesse King!), and which deliberately blows people's minds with its probabilities. This is a simple casino game called "Dragon Bones" and it is a gambling dice competition between the player and the establishment. You are given a regular 1d6 die. The goal of the game is to roll a number higher than the house's. Tom is given a non-standard 1d6 - the same as yours, but instead of a one on one side - the image of a Dragon (thus the casino has a Dragon-2-3-4-5-6 die). If the institution gets a Dragon, it automatically wins, and you lose. If you both get the same number, it's a tie and you roll the dice again. The one who rolls the highest number wins.

Of course, everything does not turn out quite in favor of the player, because the casino has an advantage in the form of the Dragon face. But is it really so? You have to calculate it. But before that, check your intuition. Let's say the win is 2 to 1. So if you win, you keep your bet and get double the amount. For example, if you bet $1 and win, you keep that dollar and get $2 more on top, for a total of $3. If you lose, you only lose your bet. Would you play? So, do you intuitively feel that the probability is greater than 2 to 1, or do you still think that it is less? In other words, on average over 3 games, do you expect to win more than once, or less, or once?

Once you have dealt with your intuition, apply the math. There are only 36 possible positions for both dice, so you can easily count them all. If you're unsure about this 2-to-1 offer, consider this: Let's say you played the game 36 times (betting $1 each time). For every win you get $2, for every loss you lose $1, and a draw doesn't change anything. Count all your likely wins and losses and decide if you will lose some dollars or gain. Then ask yourself how right your intuition turned out to be. And then - realize what a villain I am.

And, yes, if you have already thought about this question - I deliberately confuse you by distorting the real mechanics of dice games, but I am sure you can overcome this obstacle with just a good thought. Try to solve this problem yourself. I will post all answers here next week.

Game #2 - Roll of Luck

This is a dice game called Lucky Roll (also called Birdcage because sometimes the dice are not rolled but placed in a large wire cage, similar to the Bingo cage). It's a simple game that goes something like this: Bet, say, $1 on a number between 1 and 6. Then you roll 3d6. For each die that hits your number, you get $1 (and keep your original bet). If your number doesn't land on any of the dice, the casino gets your dollar and you get nothing. So if you bet on 1 and you get 1 on the face three times, you get $3.

Intuitively, it seems that in this game the chances are even. Each dice is an individual 1 in 6 chance of winning, so the sum of all three is 3 in 6. However, remember, of course, that you are adding three separate dice and you are only allowed to add if we we are talking about separate winning combinations of the same dice. Something you will need to multiply.

Once you've calculated all the possible outcomes (it's probably easier to do this in Excel than by hand, there are 216 of them), the game still looks even-odd at first glance. But in reality, the casino is still more likely to win - how much more? In particular, how much money do you expect to lose on average per game round? All you have to do is add up the wins and losses of all 216 results and then divide by 216, which should be pretty easy… But as you can see, there are a few traps you can fall into, which is why I tell you: If you think this game has an even chance of winning, you've got it all wrong.

Game #3 - 5 Card Stud

If you have already warmed up on previous games, let's check what we know about conditional probability using this card game as an example. In particular, let's imagine poker with a deck of 52 cards. Let's also imagine 5 card stud where each player only gets 5 cards. You can’t discard a card, you can’t draw a new one, no common deck - you get only 5 cards.

A royal flush is 10-J-Q-K-A in one combination, for a total of four, so there are four possible ways to get a royal flush. Calculate the probability that you will get one of these combinations.

I have one thing to warn you about: remember that you can draw these five cards in any order. That is, at first you can draw an ace, or a ten, it doesn’t matter. So when calculating this, keep in mind that there are actually more than four ways to get a royal flush, assuming the cards were dealt in order!

Game #4 - IMF Lottery

The fourth task will not be so easy to solve using the methods that we talked about today, but you can easily simulate the situation using programming or Excel. It is on the example of this problem that you can work out the Monte Carlo method.

I mentioned earlier the game “Chron X”, which I once worked on, and there was one very interesting card - the IMF lottery. Here's how it worked: you used it in a game. After the round ended, the cards were redistributed and there was a 10% chance that the card would be out of play and that a random player would receive 5 of each type of resource that had a token on that card. A card was put into play without a single token, but each time it remained in play at the beginning of the next round, it received one token. So there was a 10% chance that you would put it into play, the round would end, the card would leave play, and no one would get anything. If it doesn't (with a 90% chance), there is a 10% chance (actually 9%, since that's 10% of 90%) that she will leave the game on the next round and someone will get 5 resources. If the card leaves the game after one round (10% of the 81% available, so 8.1% chance), someone will get 10 units, another round - 15, another 20, and so on. Question: what is the expected value of the number of resources that you will receive from this card when it finally leaves the game?

Ordinarily we would try to solve this problem by finding the possibility of each outcome and multiplying by the number of all outcomes. So there is a 10% chance that you will get 0 (0.1*0 = 0). 9% that you will get 5 resources (9%*5 = 0.45 resources). 8.1% of what you get is 10 (8.1%*10 = 0.81 total resources, expected value). And so on. And then we would sum it all up.

And now the problem is obvious to you: there is always a chance that the card not leaves the game so she can stay in the game forever and ever, for an infinite number of rounds, so that the possibilities to calculate any possibility does not exist. The methods we have learned today do not allow us to calculate the infinite recursion, so we will have to create it artificially.

If you are good enough at programming, write a program that will simulate this card. You should have a time loop that brings the variable to the initial position of zero, shows a random number, and with a 10% chance the variable exits the loop. Otherwise, it adds 5 to the variable and the loop repeats. When it finally exits the loop, increase the total number of test runs by 1 and the total number of resources (by how much depends on where the variable stopped). Then reset the variable and start over. Run the program several thousand times. Finally, divide the total resources by the total number of runs, and this is your expected Monte Carlo value. Run the program a few times to make sure the numbers you get are roughly the same; if the spread is still large, increase the number of repetitions in the outer loop until you start getting matches. You can be sure that whatever numbers you end up with will be approximately correct.

If you're new to programming (or even if you are), here's a little exercise to warm up your Excel skills. If you are a game designer, Excel skills are never superfluous.

Now the IF and RAND functions will be very useful to you. RAND doesn't require values, it just produces a random decimal number between 0 and 1. We usually combine it with FLOOR and pluses and minuses to simulate a roll of the die, which I mentioned earlier. However, in this case, we're only leaving a 10% chance that the card will leave the game, so we can just check if the RAND value is less than 0.1 and not worry about it anymore.

IF has three meanings. In order, the condition that is either true or not, then the value that is returned if the condition is true, and the value that is returned if the condition is false. So the following function will return 5% of the time, and 0 the other 90% of the time:
=IF(RAND()<0.1,5,0)

There are many ways to set this command, but I would use this formula for the cell that represents the first round, let's say it is cell A1:

IF(RAND()<0.1,0,-1)

Here I'm using a negative variable meaning "this card hasn't left the game and hasn't given any resources yet". So if the first round is over and the card is out of play, A1 is 0; otherwise it is -1.

For the next cell representing the second round:

IF(A1>-1, A1, IF(RAND()<0.1,5,-1))

So if the first round ended and the card immediately left the game, A1 is 0 (number of resources) and this cell will simply copy that value. Otherwise, A1 is -1 (the card hasn't left the game yet), and this cell continues to randomly move: 10% of the time it will return 5 units of resources, the rest of the time its value will still be -1. If we apply this formula to additional cells, we will get additional rounds, and whichever cell you end up with, you will get the final result (or -1 if the card has not left the game after all the rounds you played).

Take this row of cells, which is the only round with this card, and copy and paste a few hundred (or thousands) of rows. We may not be able to do endless test for Excel (there is a limited number of cells in the table), but at least we can cover most cases. Then select one cell where you will put the average of the results of all rounds (Excel kindly provides the AVERAGE() function for this).

On Windows, at least you can press F9 to recalculate all random numbers. As before, do this a few times and see if the values ​​you get are the same. If the spread is too large, double the number of runs and try again.

Unsolved problems

If you happen to have a degree in Probability and the above problems seem too easy for you, here are two problems that I've been scratching my head over for years, but, alas, I'm not good at math to solve them. If you suddenly know the solution, please post it here in the comments, I will read it with pleasure.

Unsolved Problem #1: LotteryIMF

The first unsolved problem is the previous homework assignment. I can easily use the Monte Carlo method (using C++ or Excel) and be sure of the answer to the question “how many resources the player will receive”, but I don’t know exactly how to provide an exact provable answer mathematically (this is an infinite series ). If you know the answer, post it here... after you Monte Carlo check it, of course.

Unsolved Problem #2: Shape Sequences

This task (and again it goes far beyond the tasks solved in this blog) was thrown to me by a familiar gamer more than 10 years ago. He noticed one interesting feature while playing blackjack in Vegas: when he took out cards from an 8-deck shoe, he saw ten figures in a row (a figure, or figure card - 10, Joker, King or Queen, so there are 16 of them in a standard deck of 52 cards, so there are 128 of them in a shoe of 416 cards). What is the probability that in this shoe at least one sequence of ten or more figures? Let's assume that they were shuffled honestly, in random order. (Or, if you prefer, what is the probability that not found anywhere a sequence of ten or more figures?)

We can simplify the task. Here is a sequence of 416 parts. Each part is 0 or 1. There are 128 ones and 288 zeros randomly scattered throughout the sequence. How many ways are there to randomly interleave 128 1s with 288 0s, and how many times will there be at least one group of ten or more 1s in these ways?

Every time I took on this task, it seemed easy and obvious to me, but as soon as I delved into the details, it suddenly fell apart and seemed simply impossible to me. So don't rush to blurt out the answer: sit down, think carefully, study the conditions of the problem, try plugging in real numbers, because all the people I spoke to about this problem (including several graduate students working in this field) reacted in much the same way : "It's quite obvious... oh no, wait, not obvious at all." This is the very case for which I do not have a method for calculating all the options. I certainly could brute force the problem through a computer algorithm, but it would be much more interesting to know the mathematical way to solve this problem.

Translation - Y. Tkachenko, I. Mikheeva



Similar articles