作者 arrenwu (最是清楚哇她咩)
標題 Re: [閒聊] 想用AI寫個檔案新制抽卡模擬程式
時間 Mon Jul 27 22:41:57 2026


※ 引述《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
https://i.imgur.com/wD6J6li.jpg

--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 98.45.195.96 (美國)
※ 作者: arrenwu 2026-07-27 22:41:57
※ 文章代碼(AID): #1gPsutTd (C_Chat)
※ 文章網址: https://www.ptt.cc/bbs/C_Chat/M.1785163319.A.767.html
nineflower: 看了期望值曲線,以後無井不下池 要變無300抽不下池了1F 07/27 22:45
NakiriFubuki: 這樣怎麼看起來新的比較好?還是縱軸不是抽到的PU數?2F 07/27 22:45
arrenwu: 這個模擬 模擬的是雙PU池抽到雙PU角需要的抽數4F 07/27 22:46
spfy: 現在是指剩我不會Python了嗎5F 07/27 22:46
starsheep013: 這個只算出雙PU的,簡單舉例400抽剛好出雙PU,舊制實際上是三PU,但在這裡被歸成"拿到2PU"6F 07/27 22:47
arrenwu: 喔 還是你們比較喜歡 cmf ?8F 07/27 22:47
vhik4596: y軸有點糊,不過舊制還是比較好吧,200的時候能撤退的機率比新制高太多了9F 07/27 22:47
starsheep013: 舊制贏的期望是PU總數期望,策略不一樣11F 07/27 22:48
vhik4596: 對,舊制還要考慮這時候我已經能換第3隻PU了12F 07/27 22:48
arrenwu: 總而言之 單純要模擬數據的話其實不是太難13F 07/27 22:48
vivianqq30: 自認運氣不好的記得準備300抽再下池 :)14F 07/27 22:48
arrenwu: 大家可以跑一跑 然後自己去進行更進一步的分析 :D15F 07/27 22:49
vhik4596: 還是感謝大大,畢竟下班就懶得自己寫程式了(Xw16F 07/27 22:49
arrenwu: 我還是強調:我寫的程式不一定是對的 大家有空幫看 :)
我盡量寫成人看得懂的形式了17F 07/27 22:50
gn01102368: 我覺得等卡池出來再說 目前感覺還是有鬼19F 07/27 22:51
inte629l: numba提速,是個狠人20F 07/27 22:52
畢竟Python 那個 for-loop 的速度實在太感人了
※ 編輯: arrenwu (98.45.195.96 美國), 07/27/2026 22:54:06
pponywong: you can post code on gist....21F 07/27 22:54
rubric: 300下池是保證足夠的數字嗎22F 07/27 23:00
qqsheepu: 300後還是有非洲人就是了
不過看那圖 Y軸將近有1的刻度的人數是400抽 還滿恐怖的23F 07/27 23:00
labbat: 啊 我的numpy-2.5.1被降版為numpy-2.4.6了25F 07/27 23:16
arrenwu: 這... 2026了 你怎麼還在用 2版啊XDDD26F 07/27 23:17

--
作者 arrenwu 的最新發文:
點此顯示更多發文記錄