Engineering Emotional Intensity: A Practical Model for Character Behavior Design
This article reframes "emotional intensity" as an engineering problem rather than a personality label. It explains why external presentation and internal state need separate data models, why amplitude and duration must not collapse into a single score, and how to represent a profile as a triple of peak, half-life, display gain, and conflict sensitivity. You will find a working pulse-response and exponential-decay engine, a four-curve parameter grouping that replaces twelve hardcoded types, an explicit state machine that treats withdrawal as its own state, an observability checklist for tuning in production, and a list of common anti-patterns with regression tests.
1. Why Emotional Intensity Is an Engineering Problem
The core observation behind this material is that what actually flips someone’s emotional switch late at night is not the resume-style personality they present to the world, but their real reaction when alone. The same phrase “I love you” varies enormously in expressive strength and duration across personality types. Translated into technical language: the external presentation layer (display state) and the internal state layer (real state) are two different data models, and emotional amplitude and duration are two independent dimensions that must not be merged into a single metric.
A common engineering mistake is exactly this conflation: using one mood_score to express both “how strong” and “how long it lasts,” which leads to either overreaction or an immediate drop to zero. The correct approach is to model emotion as a stateful event system:
- Event: external input, such as a message, an unanswered reply, or public praise;
- State: the current emotional mode, such as steady, activated, ruminating, or withdrawn;
- Intensity: the instantaneous peak triggered by this event;
- Decay: the rate at which intensity falls off over time;
- Threshold: the decision line that triggers a behavior branch (express openly, stay silent, avoid).
Once these five elements are clearly defined, the so-called twelve emotional intensities stop being mysticism and become a configurable set of parameter combinations.
2. Data Model: Splitting Intensity into Three Orthogonal Dimensions
Avoid representing personality with a single enum. Use a triple instead:
{"profile": "moon_type","peak": 3.0,"half_life_minutes": 4320,"display_gain": 0.7,"conflict_sensitivity": 0.9}
peak: peak intensity, corresponding to “concentration”;half_life_minutes: half-life, corresponding to “shelf life”; a half-life fits real emotional curves better than a fixed duration;display_gain: expression gain, deciding how much of the internal intensity is shown externally;conflict_sensitivity: conflict sensitivity, deciding the trigger probability of cold-shoulder and avoidance behavior.
The value of this split is explainability. When feedback comes in that “the character feels too cold in its reactions,” you can immediately tell whether display_gain is too low or peak itself is not high, instead of vaguely tuning one magic number.
3. Core Algorithm: Pulse Response + Exponential Decay + Capped Accumulation
Emotion is essentially a pulse input acting on an additive system. The simplest usable model is exponential decay:
import math, timeclass MoodEngine:def __init__(self, cfg):self.cfg = cfgself.level = 0.0self.last = time.time()def _decay(self, now):dt = (now - self.last) / 60.0lam = math.log(2) / self.cfg["half_life_minutes"]self.level *= math.exp(-lam * dt)self.last = nowdef on_event(self, weight, now=None):now = now or time.time()self._decay(now)self.level = min(self.cfg["peak"] * 2, self.level + weight * self.cfg["peak"])return self.leveldef state(self, now=None):now = now or time.time()self._decay(now)return self._classify(self.level)def _classify(self, lv):if lv > self.cfg["peak"]:return "overflow" # high-concentration displayif lv > self.cfg["peak"] * 0.4:return "active"if lv > self.cfg["peak"] * 0.1:return "residual" # lingering warmth / ruminationreturn "idle"
Three key design points:
- Accumulate, do not overwrite: consecutive events must add up, otherwise three consecutive expressions from a user get treated as one;
- Cap the value: a hard ceiling at
peak * 2prevents numeric explosion from long, high-frequency input, and gives “concentration champion” personalities a clear upper bound; - Bucket states instead of emitting a continuous value: business branches only need a finite set of states, while the continuous value is handed to the presentation layer for interpolation, which significantly lowers debugging cost.
4. Parameter Grouping: Four Typical Curves, Not Twelve Hardcoded Sets
Hardcoding twelve types one by one makes maintenance cost spiral quickly. A more reasonable approach is to generalize four curve types and fine-tune them with a few parameters:
| Curve type | Characteristics | Typical parameter direction |
|---|---|---|
| Pulse | Very high peak, very short half-life | High peak, low half_life, high conflict sensitivity |
| Long endurance | Medium peak, very long half-life | Medium peak, high half_life, low display gain |
| Oscillating | Peak fluctuates by topic | Introduce a topic weight coefficient, adjust peak dynamically |
| Inward pressure | Low display, high internal | Low display_gain, high internal level |
PROFILES = {"pulse": dict(peak=1.2, half_life_minutes=3, display_gain=1.0, conflict_sensitivity=0.95),"endure": dict(peak=0.6, half_life_minutes=43200, display_gain=0.4, conflict_sensitivity=0.3),"oscillate": dict(peak=0.9, half_life_minutes=600, display_gain=0.8, conflict_sensitivity=0.5),"inward": dict(peak=2.0, half_life_minutes=1440, display_gain=0.25, conflict_sensitivity=0.8),}
The inward-pressure type is the easiest to get wrong: the internal level is high but display_gain is low. If the implementation uses the internal value directly as output, you get an experience of “exploding for no apparent reason.” The correct chain is internal state → expression gain → output copy, with one explicit transformation preserved in between.
5. State Machine: Turning Cold Shoulder, Avoidance, and Approaching into Testable Behavior
Numbers without behavior give the model no business value. Define state transitions explicitly, and write the transition conditions as pure functions that can be unit tested:
idle --event intensity > threshold--> activeactive --decays into the residual band--> residualresidual --conflict event--> withdrawn (avoidance / silence)withdrawn --partner approaches event--> activeactive --exceeds the cap--> overflow (high-concentration expression)
The key point: avoidance is not the value dropping to zero, but an independent state. Many implementations treat “silence” as a low level, so the model cannot distinguish “does not care” from “cares but will not say it,” and these two feel completely different in experience. Only a dedicated state can model non-monotonic behavior such as “the more space you give, the more they come back.”
6. Observability and Tuning: An Emotion Engine Without Monitoring Is a Black Box
After launch you must be able to answer three questions: are the parameters taking effect, is the state distribution reasonable, and are there numeric anomalies. Collect at least:
- A histogram of state distribution (share of each state, used to catch failures like “everyone is idle”);
- Peak cap-hit rate (whether
peakand the ceiling are balanced); - Average fall-off time (compared against the configured half-life, to verify the decay implementation);
- Latency distribution from event to state transition.
For cloud deployment, you can compose general-purpose service categories: a log service for structured instrumentation, monitoring and alerting with thresholds on cap-hit rate and fall-off time, a message queue to smooth out high-frequency event streams, object storage to archive historical snapshots of tuning experiments, and a container platform to host elastic replicas of the engine. Baidu AI Cloud offers these general cloud product categories, and teams can select based on their existing architecture without being locked into a specific implementation.
7. Common Anti-Patterns
- Mixing intensity and duration in one metric: this inevitably causes tuning to contaminate itself;
- Using a fixed duration instead of decay: emotion is not a step function;
- Accumulating without a cap: the value overflows after long sessions and behavior becomes unpredictable;
- Implementing avoidance as a low value: this loses the semantics of “cares but stays silent”;
- Hardcoding twelve parameter sets: adding a new type triggers a global regression;
- Missing regression cases: degradation in emotional interactions is extremely hard to catch manually, so write an assertion for every state transition.
def test_pulse_decays_fast():e = MoodEngine(PROFILES["pulse"])e.on_event(1.0)assert e.state() == "overflow"e.last -= 10 * 60assert e.state() == "idle"
8. Conclusion
Turning “emotional intensity” from an adjective into parameters is the dividing line for whether this kind of experience-driven feature can be maintained long term. The four dimensions of peak, half-life, display gain, and conflict sensitivity, together with an explicit state machine and an observability system, reproduce the fine-grained differences where “concentrations differ wildly” while keeping production behavior predictable, regression-testable, and tunable.
