# -*- coding: utf-8 -*-
"""
Created on Wed Jun 24 18:19:03 2020
@author: HOST1191
"""
import random
import statistics
import collections
import matplotlib.pyplot as plt
import seaborn as sns
#ルパン三世マモー電チュー振り分け
def d_furi():
d_dedama = 280
return d_dedama
#ルパン三世マモーヘソ振り分け
def h_furi():
h_furiwake = random.random()
if h_furiwake >= 0 and h_furiwake <= (3.8/100):
h_dedama = 280
h_flg = 1
elif h_furiwake > (3.8/100) and h_furiwake <= (6.4/100):
h_dedama = 280
h_flg = 2
else:
h_dedama = 28
h_flg = 0
return h_dedama,h_flg
#Pルパン三世復活のマモー連荘の関数定義
def d_renchan(d_kaisu,d_flg):
if d_kaisu == 7:
d_bunbo = 22
else:
d_bunbo = 19
ren = 1
dedama = 280
s_suru = 0
s_st = 0
g_st = 0
d_zan = 0
while s_suru < 1:
d_tyusen = random.random()
if d_tyusen <= (1/d_bunbo):
d_zan = 7 - d_kaisu
if d_zan == 0:
d_zan += 7
ren += 1
dedama += (280 * d_zan)
s_suru += 2
else:
if d_flg == 2:
s_st += 1
if s_st >= 18:
s_suru += 1
if s_suru == 2:
g_st = 0
while s_suru < 3:
d_bunbo = 22
d_tyusen2 = random.random()
if d_tyusen2 <= (1/d_bunbo):
dedama += (d_furi() * 7)
ren += 1
g_st = 0
else:
g_st += 1
if g_st >= 27:
s_suru += 1
# print ("ren=",ren)
return ren,dedama
"""ここからラッシュ評価"""
#連荘性能の評価
#ラッシュ突入回数
sikou = 10000
#連荘回数
ren1 = []
#ラッシュの出玉数
dedama1 = []
a = 0
b = 0
for sim in range(1,sikou+1):
#初当たりの振り分け処理
d_flg = 0
a = 0
d_kaisu = 0
while d_flg < 1:
if d_kaisu == 7:
d_kaisu = 1
a,d_flg = h_furi()
d_kaisu += 1
ren,dedama = d_renchan(d_kaisu,d_flg)
dedama1.append(dedama)
ren1.append(ren)
#連荘平均数
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(dedama_bunpu)
#出玉の円グラフ作表用定義
x1 = sum( x1 <= 1000 for x1 in dedama1)
x2 = sum( 1000 < x2 <= 5000 for x2 in dedama1)
x3 = sum( 5000 < x3 <= 10000 for x3 in dedama1)
x4 = sum( 10000 < x4 for x4 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)]
label = ["tan","ika","manti","manpatu"]
colors2 = ["0.3", "0.5", "0.7", "0.9", "1.1"]
plt.pie(Xgraph, labels=label, counterclock=False, startangle=90, colors=colors2,autopct="%1.1f%%")
plt.axis('equal')
d = list(ren_bunpu.keys())
e = list(ren_bunpu.values())
sns.set()
sns.set_style("darkgrid", {'grid.linestyle': '--'})
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,80), ylim=(0,1000))
ax.bar(d,e)
plt.show()
#実戦シミュレーション
sikou = 30000
sim3 = 0
sim2 = 1
for sim in range(1,8):
#実試行回数
sim4 = 0
#回転数
kaiten1 = []
#出玉推移
dedama1 = []
soudedama = 0
sim = 1
while sim4 < sikou:
t_tyusen = random.random()
sim3 += 1
sim4 += 1
if sim == 1:
t_bunbo = 22
else:
t_bunbo = 19
if sim == 7:
sim = 1
if t_tyusen <= (1/t_bunbo):
h_dedama,h_flg = h_furi()
if h_flg == 0:
soudedama += h_dedama
sim += 1
else:
sim += 1
soudedama += h_dedama
ren,dedama = d_renchan(sim,h_flg)
soudedama += dedama
sim3 = 0
else:
soudedama = soudedama - (250 / 13)
dedama1.append(soudedama)
kaiten1.append(sim4)
plt.plot(kaiten1,dedama1,linewidth=1)
plt.show()