[PYTHON] I tried to simulate how much it would cost to compose a high rare character with a social network game

At the beginning

When I was watching YouTube as usual, I was asked by a social network game, "How much does it cost to complete a high rarity character? I found a very dangerous video, so I simulated it and thought about it roughly.

conditions

Characters and equipment with a rarity of 3 to 5 will appear from the social-net gacha that you handle. High rare here refers only to characters with rarities of 4 and 5. The emission rate of each and the number of characters with that rarity

--Rare 5: 1% (34 bodies) --Rare 4: 3% (59 bodies)

It is like that. It is assumed that characters with the same rarity will appear with equal probability.

Also, instead of turning the gacha once, we will turn 11 times as one set.

Simulate

I wrote it properly in python. It seems that you can write more efficiently, but please close your eyes ()

Gacha.py


money_ave = 0
count_ave = 0
min_money = 1000000000
max_money = 0

for num in range(10000):
    box_5 = np.zeros(34)
    box_4 = np.zeros(59)
    money = 0
    count = 0
    hoshi5_comp = False
    hoshi4_comp = False

    while True:
        for i in range(11):
            a = random.randrange(0, 100)

            if(a == 0):
                hoshi5 = random.randrange(0, 34)
                box_5[hoshi5] += 1
            elif(a <= 4):
                hoshi4 = random.randrange(0, 59)
                box_4[hoshi4] += 1

        for i in range(34):
            if(hoshi5_comp == True):
                break

            if(box_5[i] == 0):
                break

            if(i == 33):
                hoshi5_comp = True

        for i in range(59):
            if(hoshi4_comp == True):
                break

            if(box_4[i] == 0):
                break

            if(i == 58):
                hoshi4_comp = True

        money += 1800
        count += 11


        if(hoshi5_comp and hoshi4_comp):
            break
    
    money_ave += money
    count_ave += count
    
    if(money < min_money):
        min_money = money
    if(money > max_money):
        max_money = money
    

money_ave /= 10000
count_ave /= 10000
print(money_ave)
print(count_ave)
print(min_money)
print(max_money)

result

After trying 10,000 times, the average number of revolutions to achieve the goal was 14046. With this social game, 11 stations can be made for about 1800 yen, so I found that it would be possible to complete a high-rare character for about 2.3 million yen.

Of all the simulations, the cheapest one was about 900,000 yen, and the most expensive one was about 7.5 million yen.

in conclusion

I couldn't think of a mathematical expected value calculation method, so I tried to simulate it, but I laughed when I found that it was quite a huge amount. I'm a favorite contributor, so I want you to do your best to the extent that you don't go bankrupt.

Recommended Posts

I tried to simulate how much it would cost to compose a high rare character with a social network game
I tried to simulate how the infection spreads with Python
I wrote a doctest in "I tried to simulate the probability of a bingo game with Python"
A memorandum when I tried to get it automatically with selenium
I tried to make a calculator with Tkinter so I will write it
When I tried to make a VPC with AWS CDK but couldn't make it
When I tried to create a virtual environment with Python, it didn't work
I want to make a game with Python
I tried to generate a random character string
I tried to make a ○ ✕ game using TensorFlow
When I tried to create a project using Python on Docker with PyCharm, it didn't work, but it worked with Docker Compose.
I tried to automatically generate a character string to be input to Mr. Adjustment with Python
A Python beginner made a chat bot, so I tried to summarize how to make it.
I tried to make creative art with AI! I programmed a novelty! (Paper: Creative Adversarial Network)
A beginner tried coloring line art with chainer. I was able to do it.
I tried to create a table only with Django
I tried to draw a route map with Python
How to make a shooting game with toio (Part 1)
I want to split a character string with hiragana
I tried to automatically generate a password with Python3
I tried to simulate the dollar cost averaging method
[Git] I tried to make it easier to understand how to use git stash using a concrete example
Since there was a doppelganger, I tried to distinguish it with artificial intelligence (laugh) (Part 2)
I made a server with Python socket and ssl and tried to access it from a browser
There was a doppelganger, so I tried to distinguish it with artificial intelligence (laughs) (Part 1)
I tried to implement a basic Recurrent Neural Network model
I tried to automatically create a report with Markov chain
How to make a simple Flappy Bird game with pygame
I tried to solve a combination optimization problem with Qiskit
I tried "How to get a method decorated in Python"
I tried to get started with Hy ・ Define a class
I tried to sort a random FizzBuzz column with bubble sort.
I tried a stochastic simulation of a bingo game with Python
I tried to divide with a deep learning language model
I tried to embed a protein-protein interaction network in hyperbolic space with Poincarē embeding of gensim
[5th] I tried to make a certain authenticator-like tool with python
[2nd] I tried to make a certain authenticator-like tool with python
[Introduction to Python] How to split a character string with the split function
[3rd] I tried to make a certain authenticator-like tool with python
[Python] A memo that I tried to get started with asyncio
I tried to create a list of prime numbers with python
I tried to implement a misunderstood prisoner's dilemma game in Python
I tried to fix "I tried stochastic simulation of bingo game with Python"
I tried to make a periodical process with Selenium and Python
I tried to make a 2channel post notification application with Python
I tried to create Bulls and Cows with a shell program
I tried to make a todo application using bottle with python
[4th] I tried to make a certain authenticator-like tool with python
[1st] I tried to make a certain authenticator-like tool with python
I tried to make a strange quote for Jojo with LSTM
I tried to make a mechanism of exclusive control with Go