Nice to meet you. I'm sakura, who recently started programming and wants to make something.
I'm currently learning Python, but I'm still in the early stages and I haven't seen the area of "completely understood."
Meanwhile, if you have made or studied something, I would like to leave it in the article.
This program was implemented using Pythonista3, which provides the Python development environment for the iPad as an app.
Implemented the basics of a simple pachislot program. There is still room for improvement, but I will introduce it for the time being.
Do you know pachislot? The same is true for those with clown patterns and grape patterns, but here I made it assuming that if the ** 3 numbers with built-in pachinko stop getting doublet, it will be a big hit **. (The one like the image) Although it is this mechanism, I do not know what the actual pachinko is like, but in this program, the big hit lottery will be done by the following method.
(1) Prepare all three-digit numbers consisting of numbers from 1 to 7. (2) Randomly take out one number from these 343 numbers. ③ If you take out doublets, you will get a big hit: confetti_ball:
Roughly speaking, it looks like this. Depending on the model, it may be from 1 to 8, but I made it assuming my favorite Symphogear (laugh).
The code has the following structure.
pachisl.py
import numpy as np
#Generate 343 dice with 3 digit numbers
dice = list()
for x in range(1,8):
for y in range(1,8):
for z in range(1,8):
dice.append(100*x+10*y+z)
#Adjusting the probability of getting doublet
prob = list()
for i in range(343):
if dice[i] == 111:
prob.append(0.00045)
elif dice[i] == 222:
prob.append(0.00045)
elif dice[i] == 333:
prob.append(0.00045)
elif dice[i] == 444:
prob.append(0.00045)
elif dice[i] == 555:
prob.append(0.00045)
elif dice[i] == 666:
prob.append(0.00045)
elif dice[i] == 777:
prob.append(0.00045)
else:
prob.append(0.99685/336)
#Extract one from 343 numbers with adjusted probability
samples = np.random.choice(a=dice,size=1,p=prob)
print(samples)
We use Numpy's np.random.choice function to create "Ikasamasai" that adjusts the probability of a roll. There is nothing applied.
You can adjust the probability in any way by changing the value. In this code, the probability of getting doublet is adjusted to 1/315. It feels like 1/319 of the actual pachinko machine.
When executed, it returns one 3-digit number, and if getting doublet, it is a big hit. There are no balls.
This time, we implemented the simplest form of pachislot. In actual pachislot, the odd-numbered tempai and even-numbered tempai have different probabilities, and 7-ten is quite rare.
Therefore, there is still room for improvement in this program. Specifically, I think it would be interesting to be able to implement a GUI, add sounds, make finer probability adjustments, and distinguish between normal and probabilistic changes.
Recommended Posts