All posts
GuidePublished Aug 13, 2026

How to Build an NPC Behavior Engine with Pressure, Emotion, and Tactics

S

Sachin Kumar

Co-founder at MistScale

9 min read

If your NPCs can talk but still feel flat, the missing piece is usually not more dialogue. It is a better behavior model. More lines make a flat character verbose rather than alive, because the thing players are reacting to is not vocabulary. It is that nothing the character does seems to come from anywhere.

A practical system tracks a small amount of state, turns events into pressure, lets pressure drift into emotion, and uses emotion to choose tactics without getting stuck in loops.

Who it's for: Game developers, narrative designers, and AI builders who want NPCs with real agency, persistent mood, and believable reactions across scenes and sessions.

Step 1: Start with the smallest useful state

  • Do not open with two dozen flags such as armed, hungry, annoyed, suspicious, and embarrassed unless you can point at the behavior each one changes. A flag nothing reads is a flag you will still be maintaining in a year.
  • A compact world model goes a long way: location, time, weather, relationship, current objective, and a few pressure or threat values.
  • Treat each variable as something that moves slowly and deliberately, not something every line of dialogue rewrites. Fast-moving state is indistinguishable from noise once several variables interact.

Step 2: Convert events into pressure, not instant emotion

  • Pressure is the input layer. Danger, embarrassment, fatigue, social tension, and unmet goals all add to it.
  • Let it accumulate across scenes so nothing snaps from calm to furious over one sentence. The accumulation is what makes the eventual change feel earned rather than random.
  • The distinction worth holding: pressure is what is happening to the character, emotion is the character's response to it. Collapsing the two is what produces characters who react to every message as though it were the first.

Step 3: Map pressure onto a gradual emotion scale

  • Use a stepped ladder instead of binary states. Something like hostile, guarded, neutral, open, warm, elated, ordered so that adjacent steps are genuinely adjacent.
  • Move one step at a time unless a single event is extreme enough to justify more. One step is almost always enough, and it is the rule that produces the sense of a personality rather than a mode switch.
  • Keep a fast layer above the slow one. The emotional colour of a single reply can spike without dragging the baseline with it, so a character can be irritated right now and still be someone who likes you.
  • Leave a residue after a shift rather than resetting the accumulator to zero. A character that just moved to guarded should still be near that edge, not back at a clean slate.

Step 4: Turn emotion into tactics, not hard-coded branches

  • Once there is a mood, let it decide how the character acts: refuse, deflect, negotiate, test, reveal, warn, help.
  • Keep tactics separate from emotion. The same feeling should produce different behavior in different contexts, and that is only possible if the two are not the same field.
  • A working tactic layer reads as the character choosing a plan. A branch reads as the character reading from a list. Players cannot articulate the difference and they notice it immediately.
  • Tactics are also where authored control belongs. Deciding that this character never refuses outright, or always warns before acting, is a constraint on the tactic layer rather than a rewrite of the personality.

Step 5: Add memory and relationship state per player

  • The same character should not treat every player identically. Store trust, prior conflicts, promises, favours, and notable events per player.
  • Memory is what explains why session 47 is different from session 1. Without it, a character with a perfect mood model still greets a long-time ally exactly like a stranger.
  • This is also where pressure gets its history. The reason a character is short with one player and patient with another should be traceable to things that actually happened between them.

Step 6: Put guardrails around loops and invented facts

  • Watch for patterns like test, reveal, test, where the character keeps rechecking a condition it already resolved and the scene stops moving.
  • Give every tactic an exit condition, and define what must change before it can be reused. Loops are almost always a system with goals and no progression rule.
  • Ground the specifics. Before a claim ships, check it against world state, stored memory, or the character brief, and rewrite or decline anything unsourced. An improvised fact does not just break the scene; it becomes something the character now believes.

Where a cognition layer fits

The pressure and emotion halves of this are exactly what MistScale runs. Interactions accumulate pressure per player rather than reacting to the last line. Mood is a ten step ordered baseline from hostile through neutral to elated, it moves one step per shift, and it keeps a residual afterwards so the character stays near the edge it just crossed. A faster per-reply emotion sits on top. Memory and relationship state are per player, and every specific claim is checked against memory, your uploaded lore, or the character brief before it ships.

Be clear about the boundary, though: MistScale does not select tactics and has no loop detector. There is no refuse, deflect, negotiate plan chooser, and nothing tracking whether a scene is progressing. What it offers is authored constraint on behaviour (a character can be set to never refuse outright, or to keep replies short) plus the state the tactic layer would need to read. The tactic engine itself, and the progression rules that stop test, reveal, test, are yours to build on top.

Start with one character and one pressure source. Push them, come back a session later, and see whether the change stuck. That tells you more than a design doc will.

Common mistakes

  • Tracking too many state variables and then trying to reason about all of them at once.
  • Making emotion change instantly instead of drifting, which reads as instability rather than reactivity.
  • Using tactics as if they were emotions, which turns the character into a script tree with extra steps.
  • Skipping per-player memory, so every returning player gets the same generic reception.
  • Letting the character repeat the same test or reveal with no progression rule, which stalls the scene indefinitely.

FAQ

What is the difference between pressure and emotion in an NPC system?

Pressure is the input: stress, danger, conflict, fatigue, unmet goals. Emotion is the state the character settles into once that pressure accumulates. Pressure changes what the character is feeling. Emotion changes how it behaves.

How do you stop NPC behavior loops like test, reveal, test?

Give each tactic an exit condition, track what has changed since the last attempt, and block a repeat unless new evidence appeared. Loops usually mean the system has goals but no progression rules.

Do I need a full dialogue tree to make this work?

No. A compact state model plus memory, mood drift, and tactic selection produces more believable behavior than a large branching tree. Trees are still useful for specific authored beats. They just should not be the whole brain.

Build NPCs that remember and evolve.

Everything in this post (memory, emotion, per-player relationships) ships in the platform today.