From 757173ac0baab7c8a210aca2fe7b0092397d1dfb Mon Sep 17 00:00:00 2001 From: SmallLeaf233 <2104448672@qq.com> Date: Sun, 9 Mar 2025 11:08:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=A6=E9=BA=A6=E9=BA=A6=E7=9C=8B=E4=BA=86?= =?UTF-8?q?=E5=BF=83=E7=90=86=E5=8C=BB=E7=94=9F=EF=BC=8C=E8=AE=A9=E5=A5=B9?= =?UTF-8?q?=E6=B2=A1=E9=82=A3=E4=B9=88=E5=AE=B9=E6=98=93=E9=99=B7=E5=85=A5?= =?UTF-8?q?=E8=B4=9F=E9=9D=A2=E6=83=85=E7=BB=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/moods/moods.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/plugins/moods/moods.py b/src/plugins/moods/moods.py index 32b900b0b..c35779f84 100644 --- a/src/plugins/moods/moods.py +++ b/src/plugins/moods/moods.py @@ -51,11 +51,11 @@ class MoodManager: # 情绪词映射表 (valence, arousal) self.emotion_map = { 'happy': (0.8, 0.6), # 高愉悦度,中等唤醒度 - 'angry': (-0.7, 0.8), # 负愉悦度,高唤醒度 + 'angry': (-0.7, 0.7), # 负愉悦度,高唤醒度 'sad': (-0.6, 0.3), # 负愉悦度,低唤醒度 - 'surprised': (0.4, 0.9), # 中等愉悦度,高唤醒度 + 'surprised': (0.4, 0.8), # 中等愉悦度,高唤醒度 'disgusted': (-0.8, 0.5), # 高负愉悦度,中等唤醒度 - 'fearful': (-0.7, 0.7), # 负愉悦度,高唤醒度 + 'fearful': (-0.7, 0.6), # 负愉悦度,高唤醒度 'neutral': (0.0, 0.5), # 中性愉悦度,中等唤醒度 } @@ -64,15 +64,20 @@ class MoodManager: # 第一象限:高唤醒,正愉悦 (0.5, 0.7): "兴奋", (0.3, 0.8): "快乐", + (0.2, 0.65): "满足", # 第二象限:高唤醒,负愉悦 (-0.5, 0.7): "愤怒", (-0.3, 0.8): "焦虑", + (-0.2, 0.65): "烦躁", # 第三象限:低唤醒,负愉悦 (-0.5, 0.3): "悲伤", - (-0.3, 0.2): "疲倦", + (-0.3, 0.35): "疲倦", + (-0.4, 0.15): "疲倦", # 第四象限:低唤醒,正愉悦 - (0.5, 0.3): "放松", - (0.3, 0.2): "平静" + (0.2, 0.45): "平静", + (0.3, 0.4): "安宁", + (0.5, 0.3): "放松" + } @classmethod @@ -119,9 +124,13 @@ class MoodManager: current_time = time.time() time_diff = current_time - self.last_update - # 应用衰减公式 - self.current_mood.valence *= math.pow(1 - self.decay_rate_valence, time_diff) - self.current_mood.arousal *= math.pow(1 - self.decay_rate_arousal, time_diff) + # Valence 向中性(0)回归 + valence_target = 0.0 + self.current_mood.valence = valence_target + (self.current_mood.valence - valence_target) * math.exp(-self.decay_rate_valence * time_diff) + + # Arousal 向中性(0.5)回归 + arousal_target = 0.5 + self.current_mood.arousal = arousal_target + (self.current_mood.arousal - arousal_target) * math.exp(-self.decay_rate_arousal * time_diff) # 确保值在合理范围内 self.current_mood.valence = max(-1.0, min(1.0, self.current_mood.valence))