想用AI寫個檔案新制抽卡模擬程式
就看了看其實也好奇 這新制到底抽到雙UP 通常期望要多少抽
目的就抽齊雙UP A角和B角 這樣花多少抽
跑個預設50萬次人數
然後紀錄做統計圖 幾個人位於10抽 20抽...400抽這樣的區間
然後檔案機率 雙UP機率
應該是各0.35%嗎?
還是說有人自己算好了 我不用自己做滿足自己好奇心= =
50萬次人數 <---- =D=
我簡單地寫了個 Python Script,
這樣花凜也有機會參與討論了
@GENE78113263
https://x.com/GENE78113263/status/207907339690…

跑新制跟舊制模擬各5000萬次差不多10秒
新舊模擬結果

每一條都是用 10抽為區間,
也就是 10抽 20抽...400抽
有錯誤也請大家提出糾正 :D
import datetime
import random
import numpy as np
from numba import njit, prange
import matplotlib.pyplot as plt
p = 0.007
@njit
def simulate_gacha_dual_pu_new_policy_single_run():
count = 0
# First pool
for i in range(1,200+1):
count += 1
if i == 100:
win = random.random() < 0.5
else:
win = random.random() < p
if win:
break
# Second pool
for j in range(1,200+1):
count += 1
if j == 100:
win = random.random() < 0.5
else:
win = random.random() < p
if win:
break
return count
@njit
def simulate_gacha_dual_pu_old_policy_single_run():
count = 0
cumulated_count = 0
# First pool
for i in range(1,200+1):
count += 1
cumulated_count +=1
win = random.random() < p
if win:
break
elif cumulated_count == 200:
# consume the ticket
cumulated_count = 0
break
# Second pool
for j in range(1,200+1):
count += 1
cumulated_count +=1
win = random.random() < p
if win or cumulated_count == 200:
break
return count
@njit(parallel=True)
def simulate_gacha_dual_pu_new_policy(runs=100000):
results = np.zeros(runs)
for i in prange(runs):
results[i] = simulate_gacha_dual_pu_new_policy_single_run()
return results
@njit(parallel=True)
def simulate_gacha_dual_pu_old_policy(runs=100000):
results = np.zeros(runs)
for i in prange(runs):
results[i] = simulate_gacha_dual_pu_old_policy_single_run()
return results
if __name__ == '__main__':
runs = 50_000_000 # 模擬次數
time_start = datetime.datetime.now()
# 新機制雙PU模擬
results_new_policy = simulate_gacha_dual_pu_new_policy(runs=runs)
# 舊機制雙PU模擬
results_old_policy = simulate_gacha_dual_pu_old_policy(runs=runs)
# 繪製 Histogram
bins = np.arange(0, 400+1, 10)
plt.figure()
plt.subplot(211)
plt.hist(results_new_policy, bins)
plt.title('New Policy')
plt.subplot(212)
plt.hist(results_old_policy, bins)
plt.title('Old Policy')
print(datetime.datetime.now() - time_start)
--
鳳雛的清楚講習


--