3
头图

Preface

I have never liked watching stick films.

However, during the eleventh period, he madly chased a drama: "Squid Game".

This film is too popular on the whole network. It has reached 111 million views worldwide, making it the world's highest-rated non-English original drama by Netflix.

The squid game has a strong metaphor of the real society, coupled with various interesting game mechanisms and exciting graphics, which has successfully attracted a lot of people's pursuit. It even includes various props in the play. .

For example, after reading it, I went to a certain treasure to buy the same type of pum:

image.png

Except for the box and needle and a hint of reduction, the quality of this candy is really not good. The thick one is almost impossible to poke with a needle. I tried it, and it became like this. . .

image.png

Not only is it difficult to dial out, but the taste is not good at all. One sells an average of more than ten yuan, one can imagine how high the gross profit is.

Of course, my article is not to complain about puffing sugar.

I don’t know if you have thought about this when watching this show: If I were a contestant, how likely would I be to survive?

It is estimated that all the friends who have watched the show will say, 100% GG. Do you know the survival probability of each game? In this article, I will analyze the survival probability of each game from the perspective of rationality and induction.

Start the text.

one

There are a total of 6 games in this play, namely: Wooden Man, Tangtang, Tug of War, Marble, Glass Bridge and Squid Game.

The game of wooden people is not difficult to live. The main reason lies in the psychological quality of everyone and the fear of the first large-scale slaughter. It is certain that the players on the right side of the game must have a better chance of surviving, because The doll turned his head from the left, which means that the person on the right will have about 1 second more time to run than the person on the left.

But in general, this cannot be summed up by mathematics. Let's use the survival probability in the play to calculate for the time being

image.png

survival probability of wooden people is: (456-255)/456=44.08%

In the second game, the sugar candy game, because everyone has different graphics and different problem-solving ideas, this game can use "cheating" methods by default, which can be dissolved with fire, and can be used to lick the dog. It also involves a little on-the-spot reaction. The same cannot be obtained by mathematical induction. We also use the survival probability in the game as a reference.

image.png

After the first game was over, everyone voted to go home, and then re-decided that there were 187 people who came to participate. In the second game, 79 people were eliminated. We can get:

The survival probability of the sugar game is: (187-79)/187=57.75%

The third game tug-of-war and the fourth game marbles are very simple. Both are eliminated half of the people, and the survival probability is 50%.

two

The fifth game is the focus, the glass bridge.

There are 18 pairs of glass. Only one glass in each pair can bear the weight of a person. When you step on the fragile glass, the glass will break and the person will fall off the GG. 16 people passed one by one.

Of course, on the premise of knowing the rules of the game, we can easily conclude that the probability of the last one surviving is the greatest. What is the probability of survival for each person with the serial number? The probability of surviving many people in this game is the greatest.

So I wrote a program for the glass bridge to simulate 100 million times. If the frequency is enough, the probability is meaningful.

The program was written in java and it took 20 minutes to write it out. code show as below:

public class SquidGame {

    public static void main(String[] args) {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        Map<Integer,Integer> map = new HashMap<>();

        //循环总次数,也就是总模拟次数
        int loopCount = 100000000;
        //桥上一共有几步
        int stepNum = 18;
        //游戏参与者一共有几人
        int peopleNum = 16;
        //每一步有多少块玻璃
        int grassNumPerStep = 2;

        //中间变量,每一次循环的生存者个数
        int surviveNum = 0;
        for (int i = 0; i < loopCount; i++) {
            surviveNum = calcSurvive(stepNum, peopleNum, grassNumPerStep);
            if (map.containsKey(surviveNum)){
                map.put(surviveNum, map.get(surviveNum) + 1);
            }else{
                map.put(surviveNum, 1);
            }
        }
        stopWatch.stop();
        System.out.println(StrUtil.format("玻璃桥步数:{}", stepNum));
        System.out.println(StrUtil.format("参与游戏的人数:{}", peopleNum));
        System.out.println(StrUtil.format("每一步块玻璃块数:{}", grassNumPerStep));
        System.out.println(StrUtil.format("模拟共耗时:{}秒", stopWatch.getTotalTimeSeconds()));
        System.out.println("*******************************************");
        System.out.println(StrUtil.format("鱿鱼游戏第5关玻璃桥模拟{}次的结果如下:", loopCount));
        for (int i = 0; i <= peopleNum; i++) {
            System.out.println(StrUtil.format("幸存者个数为{}的次数:{}", i, ObjectUtil.isNull(map.get(i))?0:map.get(i)));
        }

        int maxRateSurviveNum = map.entrySet().stream().max(Map.Entry.comparingByValue()).get().getKey();
        System.out.println("*******************************************");
        System.out.println(StrUtil.format("最终结论:存活{}人的概率为最大", maxRateSurviveNum));
        System.out.println("*******************************************");
        System.out.println();

        System.out.println("每个序号的人存活概率如下:");
        for (int i = peopleNum,j = 1; i >= 1 && j <= peopleNum; i--, j++) {
            int count = 0;
            for (int x = i; x <= peopleNum; x++) {
                count += map.get(x);
            }
            BigDecimal surviveRatePercent = new BigDecimal(count).divide(new BigDecimal(loopCount), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
            System.out.println(StrUtil.format("抽到序号为[{}]的玩家生存几率为:{}%", j, surviveRatePercent.toString()));
        }
    }

    public static Integer calcSurvive(int stepNum, int peopleNum, int grassNumPerStep){
        //目前幸存者
        int survive = peopleNum;
        //当前尝试玻璃步数序号
        int currentStep = 1;
        //目前尝试的步数还剩几块玻璃
        int currentGrassNum = grassNumPerStep;
        while(true){
            if (currentStep <= stepNum && survive > 0){
                //1.每一步的生存概率和每一步有几块玻璃有关,如果每一步有2块玻璃,
                //  死亡概率那就是50%,有3块玻璃,死亡概率就是66.6%,以此类推
                //2.如果死亡,survive就会减1,同时当前步数的玻璃数目也要减1。
                //  当然如果是按剧中的设定,每一步只有2块玻璃,那么这一步,死亡一次后,下一个人必定成功
                //3.如果当前步数此人存活,survive不变,那么currentStep就会加1,同时下一步的玻璃块数重置为设置值
                if (new Random().nextInt(1000) > 1000/currentGrassNum){
                    survive--;
                    currentGrassNum--;
                } else{
                    currentStep++;
                    currentGrassNum = grassNumPerStep;
                }
            } else{
                //当前步数等于最后一步 或者 没有生存者 的情况下,那么游戏结束
                break;
            }
        }
        return survive;
    }
}

The program used the number of people in the play to play 100 million times with the parameters of 18 steps of glass, 2 pieces of glass per step (Is there any other thing? I will increase the difficulty in the follow-up). The results are as follows:

image.png

It can be seen that the probability of surviving 7 people is the greatest. And the entire survival distribution is a typical normal distribution chart:

image.png

The first few players of each serial number have basically no hope of surviving, and the last four are basically worry-free. Those who draw the number 16 have a survival rate of 99.94%. After all, this game is still a game of character.

Of course, the premise of this simulation is that everyone follows the rules of the game. And it ruled out the situation that the person in front passed by and the person in the back didn't remember which piece of glass it was.

I searched on the Internet, and there were many discussions about the glass bridge crossing method, some said that people passed between two iron beams. Some said that 16 people were united together, holding hands and let the first person try the glass, and some said that they took off their clothes and packed them into a large cloth ball. Drag the cloth strip behind and smash the front glass with force. of.

Variety.

Of course, these methods do work in theory, but people drank a little wine in VIP and ran over all the way. Can you watch you play teamwork and become intelligent? The right to interpret the game is still in the official place. So don't think about it.

Just in terms of mathematical expectations, in the glass bridge game, in fact, 6 to 8 people should survive in the end. Only 3 survived in the play.

Could it be said that this year is just below expectations?

If you follow the standard rules of the game, everyone in front of you must have at least one chance to try the unknown two pieces of glass. However, there are many times in the play that there is a distorted side of human nature. In this way, considering from the perspective of the entire participant group, there are few opportunities to try for nothing. And a few less opportunities to try will directly lower the expectations of the entire group. This is why only 3 people survived in the end.

three

In the program, I set such a parameter: grassNumPerStep , how many pieces of glass are there in each step. The setting in the play is 2. So if I increase the difficulty and change 2 pieces of glass into 3 pieces of glass, what will be the result? (I feel more desperate when I listen)

Changing from 2 pieces to 3 pieces of glass, it seems that the probability of each step is reduced from 50% to 33.3%.

But there is also a condition hidden: when there are two pieces of glass, whether the person in front guesses right or wrong, the person behind will definitely be able to succeed further. When there are 3 pieces of glass, you still have a 50% chance of guessing wrong when the previous person fails to guess wrong. This situation is much more complicated.

Three pieces of glass continue to simulate the results of 100 million times:

image.png

Just by adding a piece of glass, the survival rate has dropped so drastically, and even the lucky one drawn to the 16th pick can only have a survival rate of less than 24%. It is estimated that with this setting, no one will participate in the sixth game. . .

Four

The last game is nothing more than one among the current survivors. In fact, the whole game does not need to be counted to know that the chance of getting money is 1/n. In other words, no matter how you used your brain, cheated, speculated, or deceived, even if you get to the last level, your final survival will depend on the most primitive brute force and violence of mankind to solve the problem.

This film has a strong reflection on society. I hope that in this impetuous and materialistic society, everyone can live on the ground and don't think about getting rich overnight. Living and persevering effort is the only way to improve happiness.

See the classmates here, please like, watch, and share.

image.png


铂赛东
1.2k 声望10.4k 粉丝

开源作者&内容创作者,专注于架构,开源,微服务,分布式等领域的技术研究和原创分享