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:

    1. {
    2. "profile": "moon_type",
    3. "peak": 3.0,
    4. "half_life_minutes": 4320,
    5. "display_gain": 0.7,
    6. "conflict_sensitivity": 0.9
    7. }
    • 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:

    1. import math, time
    2. class MoodEngine:
    3. def __init__(self, cfg):
    4. self.cfg = cfg
    5. self.level = 0.0
    6. self.last = time.time()
    7. def _decay(self, now):
    8. dt = (now - self.last) / 60.0
    9. lam = math.log(2) / self.cfg["half_life_minutes"]
    10. self.level *= math.exp(-lam * dt)
    11. self.last = now
    12. def on_event(self, weight, now=None):
    13. now = now or time.time()
    14. self._decay(now)
    15. self.level = min(self.cfg["peak"] * 2, self.level + weight * self.cfg["peak"])
    16. return self.level
    17. def state(self, now=None):
    18. now = now or time.time()
    19. self._decay(now)
    20. return self._classify(self.level)
    21. def _classify(self, lv):
    22. if lv > self.cfg["peak"]:
    23. return "overflow" # high-concentration display
    24. if lv > self.cfg["peak"] * 0.4:
    25. return "active"
    26. if lv > self.cfg["peak"] * 0.1:
    27. return "residual" # lingering warmth / rumination
    28. return "idle"

    Three key design points:

    1. Accumulate, do not overwrite: consecutive events must add up, otherwise three consecutive expressions from a user get treated as one;
    2. Cap the value: a hard ceiling at peak * 2 prevents numeric explosion from long, high-frequency input, and gives “concentration champion” personalities a clear upper bound;
    3. 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
    1. PROFILES = {
    2. "pulse": dict(peak=1.2, half_life_minutes=3, display_gain=1.0, conflict_sensitivity=0.95),
    3. "endure": dict(peak=0.6, half_life_minutes=43200, display_gain=0.4, conflict_sensitivity=0.3),
    4. "oscillate": dict(peak=0.9, half_life_minutes=600, display_gain=0.8, conflict_sensitivity=0.5),
    5. "inward": dict(peak=2.0, half_life_minutes=1440, display_gain=0.25, conflict_sensitivity=0.8),
    6. }

    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:

    1. idle --event intensity > threshold--> active
    2. active --decays into the residual band--> residual
    3. residual --conflict event--> withdrawn (avoidance / silence)
    4. withdrawn --partner approaches event--> active
    5. active --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 peak and 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

    1. Mixing intensity and duration in one metric: this inevitably causes tuning to contaminate itself;
    2. Using a fixed duration instead of decay: emotion is not a step function;
    3. Accumulating without a cap: the value overflows after long sessions and behavior becomes unpredictable;
    4. Implementing avoidance as a low value: this loses the semantics of “cares but stays silent”;
    5. Hardcoding twelve parameter sets: adding a new type triggers a global regression;
    6. Missing regression cases: degradation in emotional interactions is extremely hard to catch manually, so write an assertion for every state transition.
    1. def test_pulse_decays_fast():
    2. e = MoodEngine(PROFILES["pulse"])
    3. e.on_event(1.0)
    4. assert e.state() == "overflow"
    5. e.last -= 10 * 60
    6. assert 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.