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

跑新制跟舊制模擬各5000萬次差不多10秒
新舊模擬結果
https://i.imgur.com/zCYhfdg.png

每一條都是用 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)
--
鳳雛的清楚講習
https://i.imgur.com/23pfZv9.jpg


--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 98.45.195.96 (美國)
※ 文章網址: https://www.ptt.cc/bbs/C_Chat/M.1785163319.A.767.html
推
07/27 22:45,
1小時前
, 1F
07/27 22:45, 1F
推
07/27 22:45,
1小時前
, 2F
07/27 22:45, 2F
→
07/27 22:45,
1小時前
, 3F
07/27 22:45, 3F
→
07/27 22:46,
1小時前
, 4F
07/27 22:46, 4F
→
07/27 22:46,
1小時前
, 5F
07/27 22:46, 5F
→
07/27 22:47,
1小時前
, 6F
07/27 22:47, 6F
→
07/27 22:47,
1小時前
, 7F
07/27 22:47, 7F
→
07/27 22:47,
1小時前
, 8F
07/27 22:47, 8F
推
07/27 22:47,
1小時前
, 9F
07/27 22:47, 9F
→
07/27 22:47,
1小時前
, 10F
07/27 22:47, 10F
→
07/27 22:48,
59分鐘前
, 11F
07/27 22:48, 11F
→
07/27 22:48,
59分鐘前
, 12F
07/27 22:48, 12F
→
07/27 22:48,
59分鐘前
, 13F
07/27 22:48, 13F
推
07/27 22:48,
59分鐘前
, 14F
07/27 22:48, 14F
→
07/27 22:49,
58分鐘前
, 15F
07/27 22:49, 15F
→
07/27 22:49,
58分鐘前
, 16F
07/27 22:49, 16F
→
07/27 22:50,
57分鐘前
, 17F
07/27 22:50, 17F
→
07/27 22:50,
57分鐘前
, 18F
07/27 22:50, 18F
→
07/27 22:51,
56分鐘前
, 19F
07/27 22:51, 19F
推
07/27 22:52,
55分鐘前
, 20F
07/27 22:52, 20F
畢竟Python 那個 for-loop 的速度實在太感人了
※ 編輯: arrenwu (98.45.195.96 美國), 07/27/2026 22:54:06
推
07/27 22:54,
53分鐘前
, 21F
07/27 22:54, 21F
推
07/27 23:00,
47分鐘前
, 22F
07/27 23:00, 22F
→
07/27 23:00,
47分鐘前
, 23F
07/27 23:00, 23F
→
07/27 23:11,
36分鐘前
, 24F
07/27 23:11, 24F
→
07/27 23:16,
31分鐘前
, 25F
07/27 23:16, 25F
→
07/27 23:17,
30分鐘前
, 26F
07/27 23:17, 26F
推
07/27 23:37,
10分鐘前
, 27F
07/27 23:37, 27F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
C_Chat 近期熱門文章
PTT動漫區 即時熱門文章
14
34