The 'Spock dilemma' (aka emotions)

Interesting stuff …

It sounds like you are writing a general library for social interactions. Originally I understood you were saying the PC in your game was someone/something that could read and influence emotions telepathically. If that was the idea, then maybe that could be all the PC can do, which would not only make the implementation easier, it would focus the player on what the game is about (manipulating emotions).

I appreciate Emily Short’s comment in another thread:

I agree that it would take a very long time, but I do believe it would work. I can’t prove that to someone else though.

But I totally agree with focusing on what is most appropriate for the story at hand, not only to keep the implementation manageable, but also to communicate to the player how they are meant to interact with this particular game.

That said, I think a general social engine could still work. It looks like someone has already attempted something like this for the Unity engine. From the description, it tracks relationships between NPCs (with emotions influenced by NPC personalities), though the application that calls it is responsible for triggering it when needed and acting on its responses.

Here are a few of the challenges around building a general system:

– Completeness. Can you list all the social actions that exist even in your own culture? What about in other cultures? What about the fact that some of those verbs are much larger-scale than others (e.g. “smirk at X” vs “blackmail X” – the one being a fleeting momentary gesture, the other an extended interaction)?

– Context. The same behavior can mean radically different things in different situations. Resolving this is likely to require a knowledge base and sophistication on nearly the scale of that required to resolve natural language input; you’re probably going to need to do some machine learning.

– Resulting states. In addition to figuring out everything the player can do or any of the other characters can do, you would also have to work out what effects those interactions are going to have.

— What’s your model of human relationships? It might seem like you could have a bunch of relationship names and assign them between characters: “boss”, “parent”, “friend”, etc. But some of those relationships are objectively existent and others are subjective – I might think of you as a friend while you don’t agree that we are friends, for instance. And multiple relationships can exist between people at the same time: if you’re working in a family business, your boss might also be your uncle. So you’re going to need superpositions of possible relationships, rules for how those relationships change, rules about reciprocity and officialness of change, and so on.

— How about mutual opinions? Versu allowed characters to form opinions about others on multiple axes at once, so a character could think that another was attractive but foolish (for instance), or friendly but of low status.

— And emotional states? Often our feelings are superpositions of other, simpler emotions: you might be a little annoyed and a little amused by the behavior of a noisy toddler. Games tend to simplify that a bit, but I think a straight-up positive-negative axis is going to be way too simple for the kind of system we’re talking about here, so we need something more complex.

– Response. Are you automating your characters doing specific things in response to their emotional/relationship states? Are those actions are going to be suitable in all possible story contexts? (Hint: no, they are not.) If you’re leaving it up to authors to write in all the ways that people can react to situations, that poses a substantial authoring burden for using the engine; but finding even an acceptable set of defaults can be pretty challenging.

– Scaling and skewing the engine’s behavior for different story contexts. One of the things we had to deal with Versu was that we wanted different levels of NPC response in different stories. In a realistic drama with a two-hour running time, you want the characters to have fairly moderate, cumulative reactions to emotional inputs, so you can gradually work your way up to being close to someone. In a ten-minute farce, you want every move to be amplified to and to produce cascades of comedic results. You might think, “oh, we can just slap a scalar multiplier on any numerical changes,” but in practice there were lots of other tuning effects we had to look at.

Okay. So let’s imagine you’ve managed to model all that. Now you also have to make that model transparent enough to the player that they can act with agency and never feel like your simulation is buggy. To (very loosely) paraphrase Aristotle, game systems must appear plausible, where real life is confined only to the possible.

If you’ve ever played the game Oblivion (or any of the Elder Scrolls series of RPGs) you would know that as a player you could converse with NPCs (in Oblivion it’s a minigame) and raise (or lower) their regard for the player. Raise it high enough they sold you rare items, offered to tag along, gave you you discounts as vendors or even ignored criminal acts (when observed since you could try to sneak and be undetected). Lower it and you got the opposite effects, perhaps even the NPC initiating an attack (which could be important in order to complete a quest to kill an NPC in a manner that does not constitute a murder catching attention of the authorities).

As far as the extension goes the goal is to provide the framework but very likely will leave it up to the game to specify what should actually happen. So the rulebooks or whatever I end up using will be provided by the extension, leaving the game to set up rules, specific character values, and whatnot. The extension just provided all the glue so the game itself does not need massive boilerplate type code to get such a system going.

If I really wanted to go for broke I’d use something like support vector machines, neural nets such as LSTM (long short term memory [Schmidhuber et al.] which are likely better for this kind of time series problem) and train them to recognize patterns of actions then have their outputs deciding the character’s moods and perceptions (you would train each character’s net by using examples of how that character would react in several predefined (eg: concept) situations, then have the net extrapolate on (filtered) events as they transpire in an actual game). Inform doesn’t have them but one could add such a module to one of the glulx terps and have glulx extension opcodes for accessing the previously-trained nets.

In my own game it’s basically going to boil down to character-value rules that react to observation of various actions (or kinds of action) with each particular value handling its effect on mood and/or perception (which of course may test for the presence of other values on the observer). Then assign the character-values onto each person as appropriate. I don’t have a full-blown telepath in the game. I have a healer type character who is affected by strong feelings around her because they naturally radiate outward (as one may suspect she’s kind of shy as a result) and her powers may affect a person externally (wounds) or internally (all the other priesty type stuff). Though when her power evolves she could in theory focus on a person then concentrate to access that person’s mind (think like how Prof. Xavier can sense or influence a person via Cerebro if he focuses and concentrates on a specific person). It’s not an all-the-time thing like Deanna Troi can do in Star Trek TNG. It’s also something that can be painful since a person’s natural tendency is to defend against the intrusion and breaking down that shield causes injury. This power is obviously something that needs to be used with care, even to a willing subject (an important first step is to make sure the target is in a deeply relaxed state). Another character has a related kind of empathic power (blue mage roughly approximates her powers but there are also elements of communication, mostly in dreams) towards creatures/animals rather than people.

Emily is right in that a generalized system is too large a project since it frequently will require far more effort to cover a decently complete generality when the game the creator actually makes only uses a tiny fraction of the possibility. Not that such a project couldn’t be done but it’s a huge undertaking and would require collaboration from several authors. It’s not something one creator would make as a step in a specific game since the interaction component will consume 99.9% of the author’s available time for the project leaving none for the actual game the author wishes to make.

That’s something I’m looking at right now – what goes into a relationship between people, and how that affects their behaviour. Roles like “mother”, “friend” or “king” have an effect, but there are clearly a lot of other things too.

And there is also the interaction between emotions (as immediate reactions to events), attitudes / opinions (more constant but in flux as well) and personality (more or less fixed).

That’s a really good point; the user of such an extension would need access to enough of the system to tune it properly, too.

Here I have a slightly different vision, I think.

An alternative “use” for NPCs is just to make the experience richer and deeper, without necessarily needing to get something out of them (e.g. get them into a certain emotional state). This doesn’t imply a sandbox environment, though.

I can imagine a companion NPC that has all kinds of interesting reactions throughout the story – not enough to derail the plot (unless the player deliberately pushes the NPC towards some kind of extreme behaviour), but enough to feel like you are dealing with a real person. Not totally unlike playing a multiplayer game.

My game will be using Plutchik (via the extension) to model emotions and a character-values system (extension may provide the relation and any glue but the game itself has to define specific character-values) to model behavior/reactions. Anything needing to be more specific will be handled in a per-character manner. I’ll also be using scenes to set up/remember context (eg: global economy currently bad) since the game can activate and deactivate them at will. Properties on regions can represent localized contexts such as cultures (so non-specific NPCs may act a certain way in a particular region unless individual properties on a particular person override them).

I’ve added a follow up blog post to the previous one on emotions: NPC Emotions, part 2. It covers emotion intensity, the focus of emotions, moods and emotional openness.

This has been really interesting to look at; I’d love to know people’s thoughts if they have any.