ゴーゴージャグラー2のシミュレーション(プログラミング編)
前回のコードを応用して、Pythonで「ゴーゴージャグラー2」のスランプグラフを作成してみましょう。
設定ごとの小役・ボーナス確率の設定
ジャグラーのスランプグラフを描画するにあたって、設定が6段階あることを考慮する必要があります。
今回は、ループ処理を用いて、設定値1~6まで変更し、各設定値に対応する小役・ボーナス確率をその都度設定しています。
# ループ処理
# 1~6の設定数分ループを回す
for Setting in range(1,7):
# 差枚数を入力する変数
Total = 0
# 設定ごとの小役・ボーナス確率の設定
if Setting == 1:
Replay = 7.29
Grape = 6.82
Cherry = 33.7
BIG = 269.70
REG = 364.10
elif Setting == 2:
Replay = 7.29
Grape = 6.75
Cherry = 33.7
BIG = 268.60
REG = 336.10
elif Setting == 3:
Replay = 7.29
Grape = 6.70
Cherry = 33.7
BIG = 266.40
REG = 318.10
elif Setting == 4:
Replay = 7.29
Grape = 6.65
Cherry = 33.7
BIG = 260.10
REG = 283.70
elif Setting == 5:
Replay = 7.29
Grape = 6.59
Cherry = 33.7
BIG = 255.00
REG = 255.00
elif Setting == 6:
Replay = 7.29
Grape = 6.53
Cherry = 33.7
BIG = 242.70
REG = 242.70
else:
continue
1回転ごとの差枚計算
↑のループ処理の中に、前回作成したループ処理を組み込みます。
前回作成したループ処理を組み込んだコードが以下のコードになります。
def SlumpGraph_calc(loop):
# 結果用の箱の準備
Result1 = []
Result2 = []
Result3 = []
Result4 = []
Result5 = []
Result6 = []
# ループ処理
# 1~6の設定数分ループを回す
for Setting in range(1,7):
# 差枚数を入力する変数
Total = 0
# 設定ごとの小役・ボーナス確率の設定
if Setting == 1:
Replay = 7.29
Grape = 6.82
Cherry = 33.7
BIG = 269.70
REG = 364.10
elif Setting == 2:
Replay = 7.29
Grape = 6.75
Cherry = 33.7
BIG = 268.60
REG = 336.10
elif Setting == 3:
Replay = 7.29
Grape = 6.70
Cherry = 33.7
BIG = 266.40
REG = 318.10
elif Setting == 4:
Replay = 7.29
Grape = 6.65
Cherry = 33.7
BIG = 260.10
REG = 283.70
elif Setting == 5:
Replay = 7.29
Grape = 6.59
Cherry = 33.7
BIG = 255.00
REG = 255.00
elif Setting == 6:
Replay = 7.29
Grape = 6.53
Cherry = 33.7
BIG = 242.70
REG = 242.70
else:
continue
# 乱数範囲の設定
Replay範囲 = round(65536 / Replay)
Grape範囲 = round(65536 / Grape)
Cherry範囲 = round(65536 / Cherry)
BIG範囲 = round(65536 / BIG)
REG範囲 = round(65536 / REG)
Replay範囲_下 = 0
Replay範囲_上 = Replay範囲_下 + Replay範囲 - 1
Grape範囲_下 = Replay範囲_上 + 1
Grape範囲_上 = Grape範囲_下 + Grape範囲 - 1
Cherry範囲_下 = Grape範囲_上 + 1
Cherry範囲_上 = Cherry範囲_下 + Cherry範囲 - 1
BIG範囲_下 = Cherry範囲_上 + 1
BIG範囲_上 = BIG範囲_下 + BIG範囲 - 1
REG範囲_下 = BIG範囲_上 + 1
REG範囲_上 = REG範囲_下 + REG範囲 - 1
# ループ処理
# loopで設定した回転数分まわす
for j in range(loop):
# 1回転あたり3枚必要なので、3枚マイナス
Total = Total - 3
# 1回転ごとに乱数を生成(0~65535の範囲)
rand = random.randint(0,65535)
# 小役orボーナスの当選確認と差枚数の加算
if Replay範囲_下 <= rand <= Replay範囲_上:
Total = Total + 3
elif Grape範囲_下 <= rand <= Grape範囲_上:
Total = Total + 7
elif Cherry範囲_下 <= rand <= Cherry範囲_上:
Total = Total + 2
elif BIG範囲_下 <= rand <= BIG範囲_上:
Total = Total + 312
elif REG範囲_下 <= rand <= REG範囲_上:
Total = Total + 104
else:
# はずれだったら何もしない
Total = Total
また、各設定ごとの結果をそれぞれ別の変数に保存していきます。
# 1回転ごとに差枚数を配列に入力(設定毎)
if Setting == 1:
Result1.append(Total)
elif Setting == 2:
Result2.append(Total)
elif Setting == 3:
Result3.append(Total)
elif Setting == 4:
Result4.append(Total)
elif Setting == 5:
Result5.append(Total)
elif Setting == 6:
Result6.append(Total)
# loopで設定した回数分処理が終わった時
# 各設定ごとに差枚数を保存
if Setting == 1:
Total1 = Total
elif Setting == 2:
Total2 = Total
elif Setting == 3:
Total3 = Total
elif Setting == 4:
Total4 = Total
elif Setting == 5:
Total5 = Total
elif Setting == 6:
Total6 = Total
今回作成したコード
最後にコード全体です。シミュレーションの設定(試行回数)を行う箇所と、グラフ描画の処理を追加しています。
# coding: UTF-8
import random
import matplotlib.pyplot as plt
def SlumpGraph_calc(loop):
# 結果用の箱の準備
Result1 = []
Result2 = []
Result3 = []
Result4 = []
Result5 = []
Result6 = []
# ループ処理
# 1~6の設定数分ループを回す
for Setting in range(1,7):
# 差枚数を入力する変数
Total = 0
# 設定ごとの小役・ボーナス確率の設定
if Setting == 1:
Replay = 7.29
Grape = 6.82
Cherry = 33.7
BIG = 269.70
REG = 364.10
elif Setting == 2:
Replay = 7.29
Grape = 6.75
Cherry = 33.7
BIG = 268.60
REG = 336.10
elif Setting == 3:
Replay = 7.29
Grape = 6.70
Cherry = 33.7
BIG = 266.40
REG = 318.10
elif Setting == 4:
Replay = 7.29
Grape = 6.65
Cherry = 33.7
BIG = 260.10
REG = 283.70
elif Setting == 5:
Replay = 7.29
Grape = 6.59
Cherry = 33.7
BIG = 255.00
REG = 255.00
elif Setting == 6:
Replay = 7.29
Grape = 6.53
Cherry = 33.7
BIG = 242.70
REG = 242.70
else:
continue
# 乱数範囲の設定
Replay範囲 = round(65536 / Replay)
Grape範囲 = round(65536 / Grape)
Cherry範囲 = round(65536 / Cherry)
BIG範囲 = round(65536 / BIG)
REG範囲 = round(65536 / REG)
Replay範囲_下 = 0
Replay範囲_上 = Replay範囲_下 + Replay範囲 - 1
Grape範囲_下 = Replay範囲_上 + 1
Grape範囲_上 = Grape範囲_下 + Grape範囲 - 1
Cherry範囲_下 = Grape範囲_上 + 1
Cherry範囲_上 = Cherry範囲_下 + Cherry範囲 - 1
BIG範囲_下 = Cherry範囲_上 + 1
BIG範囲_上 = BIG範囲_下 + BIG範囲 - 1
REG範囲_下 = BIG範囲_上 + 1
REG範囲_上 = REG範囲_下 + REG範囲 - 1
# ループ処理
# loopで設定した回転数分まわす
for j in range(loop):
# 1回転あたり3枚必要なので、3枚マイナス
Total = Total - 3
# 1回転ごとに乱数を生成(0~65535の範囲)
rand = random.randint(0,65535)
# 小役orボーナスの当選確認と差枚数の加算
if Replay範囲_下 <= rand <= Replay範囲_上:
Total = Total + 3
elif Grape範囲_下 <= rand <= Grape範囲_上:
Total = Total + 7
elif Cherry範囲_下 <= rand <= Cherry範囲_上:
Total = Total + 2
elif BIG範囲_下 <= rand <= BIG範囲_上:
Total = Total + 312
elif REG範囲_下 <= rand <= REG範囲_上:
Total = Total + 104
else:
# はずれだったら何もしない
Total = Total
# 1回転ごとに差枚数を配列に入力(設定毎)
if Setting == 1:
Result1.append(Total)
elif Setting == 2:
Result2.append(Total)
elif Setting == 3:
Result3.append(Total)
elif Setting == 4:
Result4.append(Total)
elif Setting == 5:
Result5.append(Total)
elif Setting == 6:
Result6.append(Total)
# loopで設定した回数分処理が終わった時
# 各設定ごとに差枚数を保存
if Setting == 1:
Total1 = Total
elif Setting == 2:
Total2 = Total
elif Setting == 3:
Total3 = Total
elif Setting == 4:
Total4 = Total
elif Setting == 5:
Total5 = Total
elif Setting == 6:
Total6 = Total
# 結果をグラフで表示
if bool(Result1):
plt.plot(Result1, label="Setting:1")
if bool(Result2):
plt.plot(Result2, label="Setting:2")
if bool(Result3):
plt.plot(Result3, label="Setting:3")
if bool(Result4):
plt.plot(Result4, label="Setting:4")
if bool(Result5):
plt.plot(Result5, label="Setting:5")
if bool(Result6):
plt.plot(Result6, label="Setting:6")
plt.grid(True)
plt.legend()
plt.show()
if __name__ == "__main__":
# 試行回数の設定
loop = 100000
SlumpGraph_calc(loop)
シミュレーション結果の確認
今回作成したコードで試しに、8000回転(1日回したとき)の結果を出力してみましょう。
設定6が最も差枚数が多いのはわかりますが、設定1もプラス差枚を叩き出していますね。
高設定域の設定4はかなりのマイナス差枚になっています。
続いて、10倍の10日回したときの結果がこちら。
だいぶ高設定と低設定の差がはっきりしてきましたが、細かい設定は差枚数だけではわからなさそうです。
さらに10倍の100日回したときの結果がこちら。
高設定域は細かい設定まで綺麗に別れていますが、低設定域の設定2と設定3は100日回しても判断がつかないレベルです。
にほんブログ村
コメント
コメントを投稿