I tried to implement a pseudo pachislot in Python

Introduction

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.

environment

This program was implemented using Pythonista3, which provides the Python development environment for the iPad as an app.

Pseudo pachislot implemented as a beginner

Implemented the basics of a simple pachislot program. There is still room for improvement, but I will introduce it for the time being.

Mechanism of pseudo pachislot

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) 2CAF3D2A-DF32-4936-A035-3D51F35F13F9.jpeg 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).

Pseudo pachislot code

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.

Summary and outlook

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

I tried to implement a pseudo pachislot in Python
I tried to implement PLSA in Python
I tried to implement permutation in Python
I tried to implement PLSA in Python 2
I tried to implement ADALINE in Python
I tried to implement PPO in Python
I tried to implement a one-dimensional cellular automaton in Python
I tried to implement TOPIC MODEL in Python
I tried to implement selection sort in python
I tried to implement a misunderstood prisoner's dilemma game in Python
I want to easily implement a timeout in python
I tried to implement Dragon Quest poker in Python
I tried to implement GA (genetic algorithm) in Python
I tried to implement a card game of playing cards in Python
I tried to implement what seems to be a Windows snipping tool in Python
I tried "How to get a method decorated in Python"
I tried to implement the mail sending function in Python
I tried to make a stopwatch using tkinter in python
I tried to implement blackjack of card game in Python
[Python] I tried to implement stable sorting, so make a note
I want to create a window in Python
I tried playing a typing game in Python
[Memo] I tried a pivot table in Python
I tried adding a Python3 module in C
I tried to implement PCANet
I tried to implement Bayesian linear regression by Gibbs sampling in python
I tried to develop a Formatter that outputs Python logs in JSON
I tried to implement StarGAN (1)
I tried to graph the packages installed in Python
I want to embed a variable in a Python string
I tried to implement Minesweeper on terminal with python
I tried to draw a route map with Python
I want to write in Python! (2) Let's write a test
I tried to implement a recommendation system (content-based filtering)
I want to randomly sample a file in Python
I tried to implement an artificial perceptron with python
I want to work with a robot in python.
I tried to automatically generate a password with Python3
I tried to summarize how to use pandas in python
I tried drawing a pseudo fractal figure using Python
I tried to implement merge sort in Python with as few lines as possible
I tried to create a class that can easily serialize Json in Python
[Python] Deep Learning: I tried to implement deep learning (DBN, SDA) without using a library.
I tried to implement Deep VQE
I tried to touch Python (installation)
I tried to implement adversarial validation
I tried to implement hierarchical clustering
I tried to implement Realness GAN
I tried Line notification in Python
I tried to implement a volume moving average with Quantx
I tried to implement a basic Recurrent Neural Network model
[Markov chain] I tried to read a quote into Python.
I tried "a program that removes duplicate statements in Python"
I created a class in Python and tried duck typing
A story about trying to implement a private variable in Python.
I want to make input () a nice complement in python
I tried to create a linebot (implementation)
[5th] I tried to make a certain authenticator-like tool with python
I tried to summarize Python exception handling
A super introduction to Django by Python beginners! Part 6 I tried to implement the login function
I tried to convert a Python file to EXE (Recursion error supported)