-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompGachaMigrateToSuperRare.py
More file actions
98 lines (77 loc) · 2.47 KB
/
Copy pathCompGachaMigrateToSuperRare.py
File metadata and controls
98 lines (77 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import sys, random
# 試行回数
AVG_TRIALS = 10
"""
M枚分割されているコンプガチャ1枚を、
単純に出現率の少ないスーパーレアカード1枚に移行したとき、
損にならない程度の出現確率を求める
"""
def main(part):
# ガチャコンプリートまでの平均回数を求める
cnt = 0
for i in range(0, AVG_TRIALS):
cnt += getCompGachaCount(part)
# ガチャコンプリート平均回数
comp_times = cnt / AVG_TRIALS
# 上で求めた回数回したとして、ギリギリ出現する程度になる
# スーパーレアカードの平均確率を求める
cnt = 0.00
for i in range(0, AVG_TRIALS):
cnt += getSuperRareOdds(comp_times)
# 対応するスーパーレアの確率"
s_rare_odds = cnt / AVG_TRIALS
return (comp_times, s_rare_odds)
'''
part 枚分割のガチャをコンプするのに必要な回数を求める
'''
def getCompGachaCount(part):
# 分割カードを準備
p = (int)(part)
list = [False] * p # 初期状態
comp = [True] * p # コンプ状態
# 全部コンプするまで回す
cnt = 0
while(list != comp):
i = random.randint(0, part - 1)
list[i] = True
cnt += 1
return cnt
'''
times 回数回してギリギリ出現する程度のスーパーレアカードの
確率を求める
'''
def getSuperRareOdds(times):
i = 0
# 10%から0.1%刻みで減らしていく
### ここのメソッドもっといい方法ないか?
odds = 0.1
while(True):
i += 1
# レアカードが出現した場合
if (random.random() <= odds):
odds -= 0.01
i = 0
continue
# 規定回数回しきった場合、その時の確率値を返す
if times <= i:
return odds
# main method
if __name__ == '__main__':
argv = sys.argv
argc = len(argv)
if (argc != 3):
print 'usage: python %s [part] [trials]' % argv[0]
quit()
part = (int)(argv[1])
AVG_TRIALS = (int)(argv[2])
timesum = 0.0
s_raresum = 0.0
for i in range(0, AVG_TRIALS):
times, s_rare = main(part)
timesum += times
s_raresum += s_rare
print "試行 %d回" % AVG_TRIALS
print "ガチャコンプ平均回数 %f回" % (float)(timesum / AVG_TRIALS)
print "対応スーパーレア平均確率 %g" % (float)(s_raresum / AVG_TRIALS)