import random
BASE_RATE = 0.01
PITY_START = 60
RATE_INCREASE = 0.10
LIMITED_RATE = 0.75
CHARACTERS = ["沈星回·虚构妄想", "祁煜·狂热剂量", "夏以昼·附骨之痕"]
TARGET_CHARACTER = "祁煜·狂热剂量"
def simulate_until_target(target_count):
"""
模拟许愿,直到获得指定数量的定轨思念
:param target_count: 需要获得的定轨思念数量
:return: 总许愿次数, 详细抽取记录, 统计结果
"""
current_rate = BASE_RATE
pity_counter = 0
is_guaranteed = False
target_obtained = 0
total_wishes = 0
wish_history = []
total_5_star = 0
character_counts = {char: 0 for char in CHARACTERS}
character_counts["非限定5星思念"] = 0
guaranteed_triggers = 0
while target_obtained < target_count:
total_wishes += 1
if pity_counter >= PITY_START:
current_rate = min(current_rate + RATE_INCREASE, 1.0)
if random.random() < current_rate:
total_5_star += 1
if is_guaranteed:
result = TARGET_CHARACTER
is_guaranteed = False
guaranteed_triggers += 1
else:
if random.random() < LIMITED_RATE:
result = random.choice(CHARACTERS)
if result != TARGET_CHARACTER:
is_guaranteed = True
else:
result = "非限定5星思念"
is_guaranteed = True
if result == TARGET_CHARACTER:
target_obtained += 1
if result in character_counts:
character_counts[result] += 1
else:
character_counts["非限定5星思念"] += 1
wish_history.append((total_wishes, result))
current_rate = BASE_RATE
pity_counter = 0
else:
pity_counter += 1
stats = {
"总抽数": total_wishes,
"总获得5星次数": total_5_star,
"各5星思念获得次数": character_counts,
"定轨机制触发次数": guaranteed_triggers,
}
return total_wishes, wish_history, stats
target_count = 3
total_wishes, wish_history, stats = simulate_until_target(target_count)
print(f"获得{target_count}张【{TARGET_CHARACTER}】总共需要{total_wishes}抽")
print("\n=== 详细抽取记录 ===")
for wish in wish_history:
print(f"第{wish[0]}次许愿:获得【{wish[1]}】")
print("\n=== 统计结果 ===")
print(f"总抽数:{stats['总抽数']}")
print(f"总获得5星次数:{stats['总获得5星次数']}")
print("各5星思念获得次数:")
for char, count in stats["各5星思念获得次数"].items():
print(f"{char}:{count}次")
print(f"定轨机制触发次数:{stats['定轨机制触发次数']}次")