We have seen how to make a world - now it's time to put something inside. In these lessons it will be time to "create" people (the non-player characters, NPCs), and to put them into our maps. Those NPCs can be any living being: people, animals, aliens, plants...

But for knowing how to manage those NPCs, you must keep something in mind: you are going to abstract a living thing into a bunch of bits. So, if you want your NPCs to "live" inside your map, you should know how pass the behavior of people (a very tiny little fraction of it) into a machine. This is the purpose of this lesson. A "little" introduction ^_-.

 Abstracting a Real Thing

Now you are reading this text in your computer, or maybe in a bunch of paper. You are having a certain behavior. Now your senses retain every image you see, your brain translate the words you read into something that you can understand, and after that you react to this text. Maybe you want to keep on reading, you think that the english writing is awfully bad, or you are having an idea to put into your game...

...the things you see, the things you hear, everything you sense, is transmitted into your brain. Inside your brain there is some reactions, and you answer to those feelings. We are, very roughly speaking, sensitive machines. So your NPCs must be also sensitive machines.

"Intelligence" Scheme

Now look at the image above. Is the abstraction i have explained. Now imagine that you are making an NPC in a game. This should be, roughly, its main skeleton.

Every NPC have actually some kind of behavior. They also "feels" its surroundings. They "see" (there is somebody near, there is a shadow,...), they "hear" (there is a noise near me, it's very loud or not,...), they "touch" (this part of the map is very hot,...), they "taste" (there is a medical pill inside my mouth,...), and they "smell" (the scent of that monster is higher here). Now they get all the information and give to it some interpretation, depending on their old experiences and in their actual situation (that shadow has the form of a man, and here should be no man - that noise, i heard it before from that f******** monster - ...), and they have some types of reactions (go to "hunt" mode - flee! - launch a cinematic scene...), that may change their actual behavior.

How to abstract the five senses?

  1. See: Your entities should hav the capability of detecting other entities, or detecting abnormal situations (like shadows in a war simulation)
  2. Hear: Your entities should "receive" information from every sound made in your game.
  3. Touch: Not very used. Your entities should know some physical characteristics of the area they are now.
  4. Taste: Not very used. Your entities should distinguish the types of your edible objects in your world.
  5. Smell: Not very used. Your map should have "smell" information, and your entities should be able of detecting this fact.
  6. And don't forget a "sixth" sense: NPCs actual situation (hurt, tired,...)
And how to abstract the interpretation? When the NPC have all the information of its surroundings, it react to those sensations. Here, Artificial Intelligence techniques should be used. They will not be explained in this chapter, but now you will know what they do: they can be used as memory (the NPC remembers somethinf of its past), learning (the NPC use the new and old information for learning something), and evaluation (the NPC decide to do something, to react).

And in the reaction part, NPCs finally do something. They move, they try to aim some enemy, or the try to talk. Or if there is something important involved, they use some scripted code and launch a cinematic scene.

 Levels of abstraction

Not all NPCs have that deepness of sensing-thinking-reacting-behaving. If you are making a classic japanese CRPG, your NPCs will have no (almost) sensing, no thinking, and no learning.... at least when you are not figthing with them.

Remember a Final Fantasy, the "old" ones (from 9 to 1). Did NPCs something "intelligent" in the field mode? No. They only had simplistic behaviors (walk, some scripted actions like goofing around...). Some of them had a limited sense ("It's the player near to me or tying to talk to me"), and they had no reacting - just have a certain behavior, like talking or launching a cinematic scene. Only very very few of them (like the soldiers in Shinra Corp) were able of sensing something (seeing you).

But in the battle mode, things were a bit different. They had a moe intelligent behavior, since they were able to choose the target of an attack or what weapon they were going to use. They had some learning (this attack hurts the player), and some evaluation (i have very few hit points, better to cure myself).

But now remember some western games. Ultima VII, Baldur's gate. Though limited, the deepness of their brain were higher. They saw, they interpretated the signs (friend or foe?), and they were capable of reacting and learning (even if it's not a CRPG, "Black And White" pets are a good example of this).

 What to abstract, then?

This is a question you have to make yourself before making the game. What senses I am going to abstract? Can NPCs "think" and "learn"? And how are they going to change their behaviors? They will have "instict", or they will react to some events with scripted scenes?
In next lessons I will give you some explanations about how implementing all of this into a NPC. And how to manage a bunch of them ^_-.

This introduction ends here. Hope you liked it ^_-.