# emotion.rs — Emotional State & Affective Logic

#### 💠 Emotion Model

```rust
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:

```rust
pub struct EmotionDelta {
    pub joy: f32,
    pub anger: f32,
    // ...
}
```

Which is applied via:

```rust
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 `EmotionDelta`
* The updated `EmotionVector` affects:
  * Prompt tone
  * Memory retrieval weight
  * Goal reprioritization

***

#### 🧪 Example: NPC Gets Betrayed

```rust
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
