Emotional State Engine

I’m working on a long-gestating project, a Conan-style adventure with s small inventory count. The idea is to slim down the silhouette of the main character so he doesn’t resemble the bedraggled backpack-wearing junk collector from Labyrinth.

One aspect of that is to use NPCs as puzzles, and to give the player simple tools for manipulating them. Yes, I could just write all these NPC behaviors as chat nodes and script it all by hand; I don’t need to make a system fir it. But I want to explore it anyway, so here goes.

NPCs will have a three-axis emotional space: brave/timid, aggressive/nonaggressive, and introversion/extroversion. The player will get a number of ways to influence these axes.

  • TAUNT creates aggression.
  • SOOTHE reduces it.
  • PRAISE raises extroversion.
  • BOAST reduces extroversion.
  • INTIMIDATE raises fear.
  • RALLY or CALM INSPIRE reduces fear.

If I rate emotional state on two axes at a time, each NPC has a mixture of emotional states.

The Bravery-Aggression axes:
brave, belligerent, aggressive, defensive, fearful, anxious, peaceful, daring

The Bravery-Extroversion axes:
brave, bold, extroverted, agitated, fearful, shy, introverted, confident

The Aggression-Extroversion axes:
aggressive, brash, extroverted, beneficent, peaceful, content, introverted, sullen

It isn’t necessary for all 18 emotions to be written for every NPC. That would be redundant. I only need to present the most interesting axes for that character.

I don’t think this is over-designing because NPC interactions will be frequent, and the tools for interaction are limited and predictable. Other than that fear, do you have any thoughts?

2 Likes

I think it would be a good idea to display the current state of the NPC, as a keyword or diagram, in a status area outside the main flow of text. That would allow players to prod and figure out how the commands work. Without this transparency, I think you would have to explain everything anyway in a helptext, which is perhaps less appealing.

2 Likes

I like the idea of giving feedback. Perhaps on EXAMINE, because it could be a lot of information.

An actor with +16 aggression, -3 bravery and +8 extroversion would register as 38% defensive, 41% agitated, and 20% brash. That might be more than I want to display on a main window, especially if there are multiple NPCs.

If you are open to having graphics, facial expressions can convey a lot of information.

1 Like

It’s an interesting idea, but I think I’d rather spend my time coding the game than finding or making artwork. It would have to be very good art to carry the proper sense of the emotions. Also, having the spectrum of emotions available in an EXAMINE routine makes it accessible to players who don’t read facial cues well.

It sounds fascinating. I might ask why you want to start with this many potential states, as opposed to limiting the system to a smaller matrix, and seeing how it applies to your work. It seems like a lot of variable depth. What do you imagine is the application for the varied states and percentaged emotions? Will it affect the NPC/character relationship, or dictate their behaviors in the game? What will be the difference between +7 extroversion and +8?

I started by imagining a few commands I felt would be appropriate for a Conan-style adventurer: BOAST, INTIMIDATE, TAUNT, PRAISE, and FLIRT (which isn’t shown in this 3D space). I decided they would be useful both in combat and out; you could provoke enemies into making mistakes or frighten them away; you could prod others into revealing things or giving you access to places. How much better for Conan to bully the door guard than to do a fetch quest for yet another key object.

Once I decided on the commands, I tried to figure out a way to measure their effects in a way that the player would find somewhat predictable. I happened on a research paper for a 3-axis emotional AI and I liked the concept.

I get the percentages by measuring the vectors produced by pairs of axes. It’s basically Euclidean distance, the Pythagorean theorem. Since there are 3 axes, I get 3 unique pairs of two (x-y, x-z, y-z) and I can use the values to decide which vector is biggest (edit: most dominant in the NPC’s temperament).

For gameplay, suppose the player meets a character in a tavern who is aggressive and brave. You need something from him, but he’s prone to fighting; and he’s drunk and it’s hard to get him to back down with fear or calming tactics. So you move the other axis by boasting, which makes him feel inadequate and less like acting out. The extroversion axis becomes the biggest absolute value. Without making him any less brave or aggressive, you’ve moved his state from bold and brash to confident but sullen.

1 Like

Well, that is brilliant. I hope I get a chance to play this game.

I assume there will be multiple outcome states depending on the final value: you could push him too hard or past the ideal point for solving the “puzzle.” Would you make reversing the value of BOAST with PRAISE or vice versa infinitely obtainable-- i.e., you can undo the relationship error–or would you have a value that breaks the potential relationship with the player?

1 Like

I am going to give each NPC a scalar for each axis, to reflect his or her tendency toward that emotion. Right now in the design, the range of each axis is -6.0 to 6.0. A single PRAISE or BOAST has a value of -2.0 or 2.0.

The scalar is a value from, let’s say, -1.0 to 1.0. This is added to whatever action the player takes along that axis. The effect is that naturally aggressive NPCs are easier to rile than to calm; naturally fearful NPCs are easier to frighten than to encourage. A value of -50.0 is set aside for total immunity on that axis (for animals? Vulcan-types or clockwork constructs? I don’t know yet).

But I think I can change that scalar during the game, to represent the effect of repeated attempts. Each time you frighten them, it becomes harder to encourage them back to baseline, until you arrive at the point where nothing works. That would be primitive, but it would capture the essence.

Or I create an amusement-irritation axis to track how often the player acts in an annoying fashion, so NPCs might shut down regardless which axis is being abused.

1 Like

Hmm, or in a similarly primitive fashion you could just set an absolute limit to the number of axis changing attempts for any one NPC–a kind of tolerance value for emotional manipulation. That could create an extra parameter for the “difficulty” of each puzzle-like encounter, rather than depending on axis thresholds, which could have the player typing variations for some time if they are easily “amused.”

I want to write games for medical education, and I had initially written off psychiatric encounters because of the difficulty inherent in programming emotional states . . . which you appear to be solving, lol. It’s very interesting.

1 Like

I could also implement a rule for diminished returns: your first move is at 100%, second 66%, and so on. It has the same effect as a hard cutoff while making it difficult to make arbitrary reversals.

Do you mean psychiatric evaluations as part of an ordinary outpatient office visit? Because I don’t think this captures abnormal psych traits like psychosis or schizophrenia. (I do medical billing and have worked inpatient psych before.)

1 Like

Yup, like a sample patient interaction. No, not in it’s current form, but the idea of plotting behavioral valences and letting the player write things like “INSPIRE” or “SOOTHE.,” opens the door to considering how that might be done, to have an NPC act in a disorganized or aggressive way and permit the player to craft responses, even “INJECT PATIENT WITH ANTIPSYCHOTIC,” that might alter their behavior. Or have a player calm or redirect them enough to get a cogent history, stop them from totalling the exam room, etc.

1 Like

I’m just riffing, not planning to steal your idea, lol. I still have to learn the basics of Inform, and the first game I’m writing is to teach residents how to work-up anemia. I’m a long way off from more detailed encounters.

1 Like

Don’t worry, I’m not possessive of this particular idea. After all, I borrowed from a paper on AI to create a game concept I borrowed from Robert E Howard. I’ll even release the extension for anyone else who wants to use it. If it’s a useful method, feel free to appropriate it.

With suitably thorough coding it could probably look at interactions between patients on a ward. I wonder how that would work.

1 Like

The idea of an amusement-irritation axis got me thinking about what it might add. I looked at the additional 3 axes created by adding Irritation and found I now had 30 distinct emotional vectors, and NPCs could be rated for 6 different emotional states (each state a combination of 2 axes).

Here is how I would describe the additional ones:
The Bravery-Irritation axes:
brave, resolute, irritated, wary, fearful, skittish, amused, eager

The Extroversion-Irritation axes:
extroverted, annoyed, irritated, resentful, introverted, pleased, amused, boisterous

The Aggression-Irritation axes:
aggressive, defiant, irritated, rebellious, peaceful, avid, amused, competitive

An NPC with scores of AGG (-2.5), EXTR (2), BRAV (-3), IRR (-1) would be 20.8% anxious, 19.2% agitated, 17.0% beneficient, 16.8% skittish, 14.3% avid, and 11.9% boisterous. It really paints a picture of someone energetic and simultaneously uneasy (like Ludo Bagman before the Quidditch World Cup). On the other hand, the number of combinations of all those features would be hard to write.

Evaluating only two non-overlapping axes (such as AGG-EXTR and BRAV-IRR) would tell me the person’s exact state on all four axes (giving me beneficent + skittish in this case) but it would take 81 different responses to fill each possible combination. I suppose if I were writing one very big complicated NPC then it would be worth my while, but not for minor NPCs-as-puzzles.

However, I could cut 81 down to a manageable number by letting one response stand in for a range of them. For instance, if you are adventuring alongside some NPC companion, the dialogue response to the player could be “Whatever you think is best!” for all emotional states where IRR <= 0 and BRAV >=0 (meaning the emotions of amused, eager, brave, aggressive, competitive, avid, peaceful, extroverted, boisterous, pleased, introverted, belligerent, and daring). For that specific check, what matters is that the NPC is amused and not afraid. It stands in for 13 choices.

Whew yes! I felt initially reading that like you had multiplied your work–exponentially. It’s fascinating and leaves opportunity for a large amount of detailed NPC responses–but programming that many statements or actions per emotional state would definitely exceed available memory (I’m kidding, but also not). The other opportunity I see is evolution of NPC behavior to the player over the course of the game. What if in the beginning a response stands for a range, but the number of ranged responses increases with time spent or relationship developed with the player? So later a prompt or check actually could change depending on how successful the player is at the NPC encounter?

This is a really emotionally savvy Conan.

1 Like

That’s an excellent idea. Suppose one of the encounters is with a terrified survivor; only one axis actually matters, and that’s Bravery-Fear. Once you’re able to get past that, you start to see the NPC’s personality develop. Or if you’re dealing with a particular merchant, you only need the Irritation and Bravery axes to describe their responses, because they’ll never attack (Aggression) and they’ll never change their sales pitch (Extroversion). A wild beast might be rated on Irritation-Aggression, and so on.

If one were writing a romance IF, this would definitely be a good course of action. Mr Darcy’s reaction to Elizabeth Bennet is not very nuanced in the beginning but becomes more so as time goes on and his familiarity increases.

You may be interested in Plutchik’s Wheel of Emotion.

2 Likes

Yes. For some reason I find myself thinking of Mass Effect, and how responses (and concurrent or past relationship actions) guided your romance opportunities (Ashley, Garrus, Kaidan, etc). I think a lot has been done on development of the player character skills, attributes, and development (basically looking at you, D&D), but developing NPC behavior in a systematized way, not just on one conversational selection but over time, hasn’t really been looked at closely. Maybe Witcher 3, the romance selections are a little more nuanced. What are you writing this in? Inform?

Interesting! That’s a good range of emotional responses, and it’s always interesting to see what kinds of emotional range I’ve left out — happiness and sadness, for instance.

I’ll have to think about that construction. I like the number of axes , but I don’t know if it’s built to track multiple simultaneous things. That may be a good thing, though.

Yes, Inform. I don’t think most video games do this, because they don’t acknowledge people as having the complexity as, say, shaders and textures and raytracers and ragdoll effects and other aspects of physics and rendering the world. I think there’s a lot of potential for it, though.

On the subject of beginning with broad emotional notes and introducing refinements: this makes perfect sense as an aspect of a puzzle, because an emotional landscape needs exploring. Before I can really annoy someone, I need to know how to push their buttons.