emotion.rs — Emotional State & Affective Logic
Oxyde agents track a 6-dimensional emotion vector that evolves with player interaction and LLM responses. This underpins memory weighting, goal shifts, and behavioral tone.
💠 Emotion Model
pub struct EmotionVector {
pub joy: f32,
pub trust: f32,
pub fear: f32,
pub sadness: f32,
pub anger: f32,
pub surprise: f32,
}Inspired by the Plutchik wheel of emotion, this model allows nuanced emotional shifts instead of binary mood flags.
🧮 Emotional Delta
After each interaction, agents compute:
pub struct EmotionDelta {
pub joy: f32,
pub anger: f32,
// ...
}Which is applied via:
fn apply_emotion_delta(&mut self, delta: EmotionDelta)Emotion decays naturally over time via decay().
🔁 Inference Feedback Loop
The LLM’s output is parsed for sentiment/emotion
That sentiment is turned into an
EmotionDeltaThe updated
EmotionVectoraffects:Prompt tone
Memory retrieval weight
Goal reprioritization
🧪 Example: NPC Gets Betrayed
EmotionDelta {
trust: -0.6,
anger: +0.4,
sadness: +0.2
}→ Stored in memory → Trust-related memories lose priority → Future prompts become defensive or cold
🕯️ Future Extensions
Mood visualization for UIs
Emotion-triggered animations
Multi-agent emotional contagion
