I wanted to print an old design doc I'd written a few years ago, but sadly I haven't heard back from the studio I wrote it for, so I can't do that. Instead, I suppose I'll just talk about an idea I worked on once. Using the parlance of junk patents, let's call this installment of French Design - "A technique for eliciting lifelike behavior using simple tools."
I should probably start with a warning: This is going to be a largely inefficient way to do what I'm talking about, that's because of how generic it is. The point is to use nothing very simple tools- the technique can be applied in damned near any game.
Alright with all of that out of the way, let's talk about the goal: What we want to do here is make NPCs in the world behave as if they're intelligent beings when they aren't busy engaging with the player. We want them to do the things people would expect them to do, if no one was around. What they're actually doing depends heavily on the environment they're in, of course, but we'll get to that in a second.
First, let's talk about our tools. We're going to have to make a few assumptions as to what tools we have available, but it's a pretty simple list:
As you've probably guessed by now, what we're going to do here is encode some data in the world objects that tells NPCs how to use them (#4 on the list above). It's the first step towards building a system that will let an NPC which objects to use and it's also the way you message intelligence to the players. Basically, if you place a chair in the world, the chair contains something that says "hey NPC, here's how you sit on me." Since the animation is embedded in the object, any NPC in the world will now know how to "sit" on a chair even if they had no such ability, before. If you do it right, the NPC will even know where to put its backside and what direction to face when sitting. Despite this, if you do it well, only NPCs that it would make sense to see sitting around will ever use it.
Now our NPCs have their "smarts" - they how to logically handle the objects in the world around them when the time comes and since tool #3 on the list is the NPC's ability to find and get to those world objects, all that's left then is to figure out how to make the NPC decide what to do. That's where those three variables come in handy - it's time to use the first two tools on the list.
We'll start by giving each NPC the following imperatives:
Believe it or not, all it takes for this to work now is to assign some values to the NPCs (Tool #1 on the original list and if you're going for added flair, the per-NPC rates mentioned in tool #2), place some NPCs and world objects in the world and turn it on. When you do, here's what will happen:
Your NPCs that aren't aware of the player will check the variables they maintain (let's call them X, Y and Z), pick the one with the largest value and move towards it to interact with it. Doing so will adjust the values of X, Y and Z for that NPC and when it's done interacting, that will matter when it decides what to do next. Those variables will also all be increasing by a fixed amount every second or every game tick (whatever your base of unit of time is).
So, you might be asking "why 3 variables and not 1?" And that's a valid question. After all, it's three times as much work for the NPC to go through when it decides what it wants to do, but having those three variables is pretty important to tuning the "smarts" of your NPCs. Those variables and the list of things each NPC can and can't do (if you implement that) represent two of the high-level "knobs" you can turn to tune how the room behaves.
For example, you could decide that X represents an NPC's desire to do work, Y represents an NPC's desire to slack off and Z represents a random element or chaos factor you add just for fun. Based on the idea that each variable represents a specific desire, you can set up NPCs to have their own personalities, which will be portrayed by their choice of what to interact with in the world. A chaotic NPC might increment Z at a faster rate than X or Y, for example, or a workaholic might never increment Y except as a result of using objects.
In other words, what we've put together here with our simple tools is a poor man's need based AI that runs in the background and makes the characters do something interesting when they'd otherwise be idle. Sure, there are a lot of holes in the system I laid out -- the most notable being that nothing is done to ensure two NPCs won't try to use the same object at the same time -- but the core of the system is sound and the edge cases aren't as numerous as you might think. Setting up the data can be a little time consuming, depending on your tools, but that really depends on your editors or apps, to be honest.