This commit is contained in:
bridge
2025-11-26 21:37:05 +08:00
parent 54cb096bd8
commit 3f7bed61fe
3 changed files with 9 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
"""
长期目标模块
为角色生成和管理长期目标(3-10年
为角色生成和管理长期目标(5-10年
"""
from __future__ import annotations
from dataclasses import dataclass
@@ -34,9 +34,9 @@ def can_generate_long_term_objective(avatar: "Avatar") -> bool:
规则:
1. 已有用户设定的目标,永不自动生成
2. 无目标时,可以生成
3. 距离上次设定 <3年,不生成
3. 距离上次设定 <5年,不生成
4. 距离上次设定 ≥10年必定生成
5. 距离上次设定 3-10年按概率生成渐进概率
5. 距离上次设定 5-10年按概率生成渐进概率
Args:
avatar: 要检查的角色
@@ -56,13 +56,13 @@ def can_generate_long_term_objective(avatar: "Avatar") -> bool:
years_passed = current_year - avatar.long_term_objective.set_year
if years_passed < 3:
if years_passed < 5:
return False
elif years_passed >= 10:
return True
else: # 3-10年之间
# 渐进概率:3年时10%随时间推移逐渐增加接近10年时接近100%
probability = (years_passed - 3) / 7 * 0.9 + 0.1
else: # 5-10年之间
# 渐进概率:5年时10%随时间推移逐渐增加接近10年时接近100%
probability = (years_passed - 5) / 5 * 0.9 + 0.1
return random.random() < probability