Thursday, June 14, 2012

Social NPCs

Man, what a depressing essay to rewrite. The first version was deleted by a mysterious act of god - by which I mean Google saved over it with an empty body of text. So I'm going to write it again. But I'm going to do it while sighing heavily and looking very put-out.

Social NPCs are kind of a last-decade topic, but I don't care, I'm going to talk about them anyway.

Most games where you can socialize with the NPCs, the NPCs boil down to "I like or don't like you". This is "one axis" socialization. It's boring and easily gamed.

You can expand the number of axes, but you start to run into expression problems. How can the player tell that an NPC trusts them but doesn't like them, and why does it matter? What effect upon the game world will the NPC have if they like you and trust you, instead?

A lot of people have posited a lot of different models. Here's the simplest one I could think up - the simplest one that resulted in complex, fun, adaptive social behavior.

I call it the "Fuck Google for Making Me Write this Twice" model, or the FG algorithm for short. (Actually "face & gain" algorithm, but whatever.)

Every NPC has a confidence level. This determines how likely they are to come up with or participate in risky plans. Someone with a high confidence level will want to go out and kill monsters, or build a space ship, or talk to the weird tentacle alien, or whatever the game world's plans are like. Someone with a low confidence level will generally resist such plans, and tend to want to take the lowest-risk action. Which is frequently "stay home and prune the hedges".

There are two kinds of social events. One is the gain event, one is the face event.

Gain events happen whenever an NPC succeeds or benefits. Gain events affect an NPC's confidence, so they may grow more or less confident depending on your (and their) actions. Gain events happen naturally during a plan's execution: if it works out, the participants all get a positive gain event. If it fails, a negative one. You can also have gain events in response to things you didn't do, such as being given gifts or having continuous bad luck.

Face events happen whenever an NPC seems particularly strong or weak to those around them. These are not linked to anyone's confidence levels, but they will change an NPC's mood for some length of time. Face events most commonly happen at the same time as gain events: plans succeeding or failing (in front of people). However, they can also happen when events cause someone to look cool or foolish even if they took no action to do so.

These events are saved. Instead of saying English words such as "trust", we would think of it as "they have seen you gain confidence and face many times". Instead of "like", we might say "you have helped them gain confidence and face many times."

In addition, depending on how you craft your event structure, a lot of really organic NPC behavior can arise.

For example, you might do an event in front of as many people as possible, so the confidence gain and face events are as large as possible. Or, if you're uncertain of success, you might do the plan on the sly, hiding it from people, so it affects your confidence but not your face.

You might execute a plan to gain confidence or face, while the end result of that plan might cause someone else to have their confidence or face affected. Bullying would be to push their face down, or perhaps you're a carebear who helps them gain confidence. Depends on the personality written into the NPC and the structure of the events.

Similarly, when the player enters the stage, they will find it somewhat complex to simply optimize their friendships.

For example, if they help their new friend gain as much face and confidence as possible, they will be very well liked by their new friend... but their new friend will basically lead them around by the nose and tell them what to do. This is quite separate from what the in-world results of your plans did.

So maybe you farm face without confidence... except then you have an issue where not everything is determined by the total of both kinds of events. If you've helped someone gain face but not confidence, their plans (confidence-based) are not going to include you, even though they will be happy to hang out with you.

Or maybe there's a struggle to keep an overconfident friend from self-destructing due to his doomed, aggressive planning. Well, maybe the best way to do that is to simply make sure nobody notices him when he's doing something, so that when he fails he loses confidence but not face.

And, of course, NPCs can vary. This one starts nervous, that one starts overconfident. That one considers a high charisma to be equivalent to you gaining face events, while the one over there considers a high intellect to be equivalent to you gaining confidence events.

Everything ends up depending on the scaffold: there are definite limitations. And, of course, depending on how much smoke and how many mirrors you use, the lack of an intelligent social system may be quite obvious. It's not terribly realistic, but if we wanted to be realistic then socializing would be a giant pile of obvious optimizations.

All this requires to be interesting is a wide variety of plans that alter the shared world, and a predictable scaffold of alone/with friends/in a crowd schedules to give you a variety of face options. I've tested it with some prototypes in different kinds of games, and it seems to work okay in all of them, whether we're talking about plans being very rare and largely preprogrammed or common and done on the fly.

The key is that their opinion of you is based on how much confidence they've seen you gain (respectish), how much face they've seen you gain (leadershippish), how much confidence you've helped them gain (mentorish), and how much face you've helped them gain (lackeyish).

And now I'm done. Again.


Noah said...

I know it's too late... but the previous essay made it to my rss reader before being deleted.

So, if you want it for some reason, let me know.

Craig Perko said...

Nah, it's more fun being grumpy and put-out. But thanks!

C4Cypher said...

Thank you, just, thank you. It makes my head hurt to watch millions of dollars get poured into making AAA titles, even complex open world RPG's such as Mass Effect or the Elder Scrolls, only to have NPC characterization seem stilted at best (the most forward thinking RPG developer's such as Bioware). The technology has moved past this point, but the industry is fixated on production values.