むるおか君のPythonパチンコシミュレーション

Pythonを使ってパチンコの新台解析やってます。たまに自分が処理したい作業のGUIも作ったり

P革命機ヴァルブレイヴ2のpythonシミュレーションコード

# -*- coding: utf-8 -*-
"""
Created on Wed Jul  1 10:56:29 2020

@author: HOST1191
"""
import random
import statistics 
import collections
import matplotlib.pyplot as plt
import seaborn as sns
#ヘソ振り分け
#フラグ設定
#1.電サポST70回
#2.電サポ8回ST70回
#3.時短100回
#4.電サポ8回通常 ただし潜伏は時短100回 def h_furi(): h_furir = random.random() h_dedama = 0 h_kakuhen = 0 if h_furir >= 0 and h_furir < 25/100: h_dedama += 1400 h_kakuhen = 1 elif h_furir >= 25/100 and h_furir < 38/100: h_dedama += 420 h_kakuhen = 1 elif h_furir >= 38/100 and h_furir < 50/100: h_dedama += 420 h_kakuhen = 2 elif h_furir >= 50/100 and h_furir < 89/100: h_dedama += 420 h_kakuhen = 3 elif h_furir >= 89/100 and h_furir < 100/100: h_dedama += 420 h_kakuhen = 4 return h_dedama,h_kakuhen def s_furi(): s_furir = random.random() s_dedama = 0 s_kakuhen = 0 if s_furir >= 0 and s_furir < 25/100: s_dedama += 1400 s_kakuhen = 1 elif s_furir >= 25/100 and s_furir < 38/100: s_dedama += 420 s_kakuhen = 1 elif s_furir >= 38/100 and s_furir < 50/100: s_dedama += 420 s_kakuhen = 1 elif s_furir >= 50/100 and s_furir < 89/100: s_dedama += 420 s_kakuhen = 3 elif s_furir >= 89/100 and s_furir < 100/100: s_dedama += 420 s_kakuhen = 3 return s_dedama,s_kakuhen #電サポの振り分け def d_furi(): d_furir = random.random() d_dedama = 0 d_kakuhen = 0 if d_furir >= 0 and d_furir < 2/100: d_dedama += 280 d_kakuhen = 0 elif d_furir >= 2/100 and d_furir < 4/100: d_dedama += 980 d_kakuhen = 0 elif d_furir >= 4/100 and d_furir < 6/100: d_dedama += 560 d_kakuhen = 0 elif d_furir >= 6/100 and d_furir < 13/100: d_dedama += 1400 d_kakuhen = 1 elif d_furir >= 13/100 and d_furir < 44/100: d_dedama += 980 d_kakuhen = 1 elif d_furir >= 44/100 and d_furir < 69/100: d_dedama += 560 d_kakuhen = 1 elif d_furir >= 69/100 and d_furir < 100/100: d_dedama += 560 d_kakuhen = 1 return d_dedama,d_kakuhen #連荘 def renchan(flg): ren = 0 suru = 0 st = 0 dedama = 0 rush = 0 while suru < 1: #転落抽選 #確変 r_tyusen = random.random() st += 1 if flg == 0: ren += 1 furideda,flg = d_furi() dedama += furideda st = 0 elif flg == 1: rush = 1 if r_tyusen <= (1/32.0): ren += 1 furideda,flg = d_furi() dedama += furideda st = 0 else: if st >= 70: suru += 1 elif flg == 2: if st < 12: if r_tyusen <= (1/32.0): ren += 1 furideda,flg = d_furi() dedama += furideda st = 0 else: dedama -= 25 if r_tyusen <= (1/32.0): ren += 1 furideda,flg = s_furi() dedama += furideda st = 0 else: if st >= 70: suru += 1 elif flg == 3: if r_tyusen <= (1/319.7): ren += 1 furideda,flg = d_furi() dedama += furideda st = 0 else: if st >= 104: suru += 1 else: if r_tyusen <= (1/319.7): ren += 1 furideda,flg = d_furi() dedama += furideda st = 0 else: if st >= 12: suru += 1 # print ("ren=",ren) return ren,dedama,rush sikou = 100000 #連荘回数 ren1 = [] #ラッシュの出玉数 dedama1 = [] rush1 = [] for sim in range(1,sikou+1): #初当たりの振り分け処理天井考慮 ren = 0 dedama = 0 sim3 = 0 end1 = 0 while end1 < 1: t_tyusen = random.random() sim3 += 1 if t_tyusen <= (1/319.7): h_dedama,h_kakuhen = h_furi() ren,dedama,rush = renchan(h_kakuhen) ren += 1 dedama += h_dedama end1 += 1 dedama1.append(dedama) ren1.append(ren) rush1.append(rush) #連荘平均数 m1 = statistics.mean(ren1) m2 = statistics.mean(dedama1) #連荘と出玉の整理 ren1.sort() dedama1.sort() #print ("連荘数=",ren1) #print ("出玉数=",dedama1) print('連荘平均: {0:.2f}'.format(m1)) print('出玉平均: {0:.1f}'.format(m2)) m3 = 250 / (m2 /319.7) print('等価ボーダ:{0:.2f}'.format(m3)) rush_bunpu = collections.Counter(rush1) print("分布=",rush_bunpu) #print('ラッシュ突入回数:',rush1.count('1')) #m4 = 1/( rush1.count('1') / sikou ) #print('ラッシュ突入分母:{0:.2f}',m4) #ラッシュ性能評価(ラッシュ入った時点からの出玉調査) sikou = 100000 #連荘回数 ren1 = [] rush1 = [] #ラッシュの出玉数 dedama1 = [] for sim in range(1,sikou+1): #初当たりの振り分け処理天井考慮 ren = 0 dedama = 0 sim3 = 0 end1 = 0 while end1 < 1: h_dedama,h_kakuhen = d_furi() ren,dedama,rush = renchan(h_kakuhen) ren += 1 dedama += 1400 end1 += 1 dedama1.append(dedama) ren1.append(ren) rush1.append(rush) #連荘平均数 m1 = statistics.mean(ren1) m2 = statistics.mean(dedama1) #連荘と出玉の整理 ren1.sort() dedama1.sort() #print ("連荘数=",ren1) #print ("出玉数=",dedama1) print('ラッシュ連荘平均: {0:.2f}'.format(m1)) print('ラッシュ出玉平均: {0:.1f}'.format(m2)) ren_bunpu = collections.Counter(ren1) dedama_bunpu = collections.Counter(dedama1) #print("分布=",ren_bunpu) #print(ren_bunpu) #出玉の円グラフ作表用定義 x1 = sum( x1 <= 1000 for x1 in dedama1) x2 = sum( 1000 < x2 <= 2500 for x2 in dedama1) x3 = sum( 2500 < x3 <= 5000 for x3 in dedama1) x4 = sum( 5000 < x4 <= 7500 for x4 in dedama1) x5 = sum( 7500 < x5 <= 10000 for x5 in dedama1) x6 = sum( 10000 < x6 <= 20000 for x6 in dedama1) x7 = sum( 20000 < x7 <= 30000 for x7 in dedama1) x8 = sum( 30000 < x8 <= 40000 for x8 in dedama1) x9 = sum( 40000 < x9 for x9 in dedama1) #Xgraph = ["{0:.1f}".format(x1/sikou*100),"{0:.1f}".format(x2/sikou*100), # "{0:.1f}".format(x3/sikou*100),"{0:.1f}".format(x4/sikou*100), # "{0:.1f}".format(x5/sikou*100),"{0:.1f}".format(x6/sikou*100), # "{0:.1f}".format(x7/sikou*100),"{0:.1f}".format(x8/sikou*100), # "{0:.1f}".format(x9/sikou*100)] #colors2 = ["0.3", "0.5", "0.7", "0.9", "1.1"] #初当たり10万回に対する出玉別出現回数 print('***初当たり10万回に対する出玉振り分け値***') print("x=",x1,x2,x3,x4,x5,x6,x7,x8,x9) d = list(ren_bunpu.keys()) e = list(ren_bunpu.values()) sns.set() sns.set_style("darkgrid", {'grid.lines1tyle': '--'}) sns.set_context("paper", 1.0, {"lines.linewidth": 1}) sns.set_palette("winter_r", 2, 1) sns.set('talk', 'darkgrid', 'dark', font_scale=1.0, rc={"lines.linewidth": 10, 'grid.linestyle': '--'}) fig, ax = plt.subplots(figsize = (10,5)) ax.set(xlabel ='ren', ylabel='occcurs', xlim=(0,30), ylim=(0,50000)) ax.bar(d,e) #実戦シミュレーション sikou = 3000 i = 0 for sim in range(1,9): #初当たりの振り分け処理天井考慮 sim4 = 0 sim3 = 0 i += 1 #回転数 kaiten1 = [] #出玉推移 dedama1 = [] soudedama = 0 fig = plt.figure() fig.subplots_adjust(left=0.2) while sim4 < sikou: t_tyusen = random.random() sim4 += 1 if t_tyusen <= (1/319.7): h_dedama,h_kakuhen = h_furi() ren,dedama,rush = renchan(h_kakuhen) ren += 1 dedama += h_dedama soudedama += dedama else: soudedama = soudedama - (250 / 18) dedama1.append(soudedama) kaiten1.append(sim4) plt.plot(kaiten1,dedama1,linewidth=1) fig.savefig("%04.f"%(i)+".jpg")