您现在的位置是 : 首页  >  行业聚焦  > 正文

世界头条:星穹铁道抽卡模拟python程序

日期:2023-05-15 01:12:59 来源:哔哩哔哩

import random

yourcount = 340  # 专票总数在这里填入你的专票数量

totalup = 2  # 填入up角色总数


(相关资料图)

S = [0] * (totalup + 2)

morethantotalup = 10000

def simulate_event():

num_iterations = yourcount  # 总共的事件次数

a_probability = 0.6 / 100  # 事件 五星 的初始概率

initial_b_sequence_length = 73  # 连续发生 B 事件的次数

a_probability_increment = 6 / 100  # 事件 五星 概率的增加量

a_reset_iteration = 90  # 重置事件 五星 概率的迭代次数

c_d_probability = 0.5  # 事件 五星 发生时 up 和 常驻 的概率

a_happened = 0

d_happened = 0

count = 0

c_count = 0  # 事件 up 发生的次数

d_count = 0  # 事件 常驻 发生的次数

a_probability_current = a_probability  # 当前事件 五星 的概率

for iteration in range(1, num_iterations + 1):

if iteration > 1 and a_happened == 1:

a_probability_current = a_probability  # 达到重置迭代次数时,重置事件 五星 的概率

if random.random() < a_probability_current:

# Event 五星 发生

a_happened = 1

count = 0

if random.random() < c_d_probability or d_happened == 1:

# Event up 发生

c_count += 1

d_happened = 0

else:

# Event 常驻 发生

d_count += 1

d_happened = 1

else:

# Event B 发生

a_happened = 0

count = count + 1

if count <= initial_b_sequence_length:

continue

# 检查是否连续发生了 B 事件

b_sequence = True

if b_sequence:

a_probability_current = min(1, a_probability_current + a_probability_increment)  # 增加事件 五星 的概率

return c_count, d_count

for i in range(1, 10001):

c_count, d_count = simulate_event()

for upcount in range(1, totalup + 1):

if c_count == upcount:

S[c_count] += 1

for upcount in range(1, totalup + 1):

morethantotalup = morethantotalup - S[upcount]

for upcount in range(1, totalup + 1):

print(f"up角色为{upcount}的概率: {S[upcount] / 10000}")

print(f"up角色大于{totalup}的概率: {morethantotalup / 10000}")

标签:

推荐