Advertisement

Practical solutions to the 'Dumb NPC' problem

Started by February 22, 2004 06:53 PM
46 comments, last by Kylotan 20 years, 11 months ago
Ok, we all see plenty of people post on here about how NPCs are stupid in many games. We also see a subset of those people say that developers are stupid for making them that way, but in fact it''s very hard to create computer algorithms that can simulate millions of years of evolution, thousands of years of cultural development, and a decade or two of personal learning; the 3 main sources of information that allow real humans to act they way they do. So I''d like to have some intelligent discussion on how to get around this problem, based on practical and implementable building blocks, rather than the usual pie-in-the-sky discussion. To start, I''ll highlight what I think are some of the symptoms of a ''dumb NPC'', in the hope that removing enough of the symptoms will allow a player to pretend the NPC is intelligent. Oblivious to danger. Ever played an RPG where, for some reason, a monster has strayed close to town, and is hacking lumps out of you while local farmers mill around as if this is normal and not a threat? I have. ''The autocue''. NPCs in many games have scripted lines to deliver hints, plot development, and so on. Sadly, they often repeat the exact same line each time you speak to them, and worse still, 100 different people might say the same thing, with a slight change to the subject matter. How can you believe someone is real when what they say is so obviously scripted? Amnesia. This follows from the last point. I hate it when NPCs forget you already talked to them. Real-world people remember who they spoke to - within reason - and adapt their conversation accordingly. They may also adapt their behaviour. However many NPCs don''t care if they already argued with you, or if you shot them before leaving the area, or if you were the one who liberated their town on your last quest. Do they have no lives? I''m currently playing Might and Magic 6 where I see peasants happily marching around at 3am. In all fairness, M+M6 doesn''t have any indoors areas where they would go, but to see them out and about at that time just drives home how fake the settlement is. Real people have families, jobs, hobbies, and schedules. They don''t walk around randomly 24/7/365. Ok, that''s 4 symptoms. Doubtless there are others. Now here are my suggestions for starting to fix the above. Being oblivious to danger should be simple to fix. Most non-player characters in the game will be flagged as either aggressive or peaceful, and peaceful characters should fear aggressive characters of a similar or higher strength level. The action to take to resolve a ''fear'' state should be to run away, which is a simple reverse-pathfinding algorithm. Additionally, aggressive monsters shouldn''t only attack players; they should attack whatever is a valid target, which is probably any other character of a lower strength level than themselves. If you don''t want your key NPCs getting killed this way, flag them as important and have death just knock them unconscious for a bit. The autocue problem is a little harder. Obviously the important lines have to be written as you probably want your best writer to make every word count. But if you have any sort of generic text, it might be worth creating a basic Backus-Naur Form grammar that can easily generate a wide variety of potential sentences. An approach that goes the other way might be to reduce conversation to being symbolic, so that deficiencies in the language are never shown. Amnesia is easy to treat if you give each NPC a few flags to mark key events with. eg. It''s important to set aside a flag so that an NPC can greet you differently the second and subsequent times they see you. This is a useful guide to any player who is trying to make sure they''ve talked to someone before. Also have the NPC check the player''s achievements list. Don''t talk about the goblins at the keep if the player completed the "eradicate all goblins in the keep" quest already, or at least thank the player. NPCs should also remember if you injured them, and either be aggressive towards you or at least be less positive in their communication. It only requires 1 bit of storage to remember whether you''ve hurt a given NPC or not, and not much more to store a little angry message for that NPC to show you when you next talk to them. Giving NPCs lives and a schedule is not quite as straightforward. But it''s perfectly possible, and was done with 10 year old technology too, in games like Ultima 7. A starting point is to ensure your game has a sense of time. Then, have your NPCs maintain a list of what they''re doing at any given time, and where they''re doing it. This reduces the problem down to a basic pathfinding issue to get from place to place, and maybe 10-30 different scripts for various types of activity such as sleeping, wandering, drinking in the tavern, enjoying archery practice, and so on. Have your NPC check roughly every hour or so whether they''re in the right place or not. If not, set them off walking and check back in a minute. If they are, make sure they''re doing the right thing. Now you have NPCs that wake up at 6am, go to their shop at 7am, work on the forge all day, wander to the tavern at 6pm, drink there until 10pm, and then go home to sleep. Wouldn''t that feel much more like a real person than the ''permashopkeeper'' we see too often? I''m interested in any opinions on the things I''ve raised above, or any other symptoms we could address, and indeed in any attempted solutions for them. [ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]
Just depends on what the game developer wants to do... one of the old Ultima games that I played on the Apple II addressed just about all of those... at night, the shops were locked and people were off the streets... if you wanted in a store, you had to break in... if you were rude to someone, they remembered it...

Some of the newer games (like Splinter Cell) address the dumb npc problem.. (ok, ok, it''s not an rpg if they find a body, they pull out their gun and start looking for you...

I think the answer is that yes, all of these things could be addressed, but it might bog down the cpu... course, if they effectively covered several of those on the Apple II... Course, if you''ve got a larger arena with more people, and they''ve all got to remember if you''ve treated them nasty, if they''ve heard anything, etc.... it gets more complicated.

But nothing you mentioned *couldn''t* be addressed.... I guess the question is why don''t more games address those things... which I think is what you asked? ;-)

I guess none of the address the intelligent conversation complaint... that just requires a lot of scripting.... Deux Ex did a good job of that, if I recall correctly... but it''s been quite a while since I played it...

-Ascent
Advertisement
Well, I think the autocue problem is also a subjective thing. Although it doesn''t add more to the game necessarily, it''s annoying when you can no longer review the information that an NPC has given you when playing a game like an RPG. That''s probably something to keep in mind too.

The "not sensitive to danger" thing is probably best by giving them some kind of attitude towards hostiles and having them respond to hostile creatures. This way, you could have some NPCs run away and others stand up and fight.
I think its more of a problem of time and money. If your game is already behind, what are you most likely to cut out? It would probably be something that would have minimal impact on the gameplay. Only really good designers realize that NPCs are the player''s main link to game information. Without NPCs, most games would fall to pieces simply because the player would have no way to figure out quest, or get information about the villians.
quote:
Original post by ShadowWolf
Well, I think the autocue problem is also a subjective thing. Although it doesn''t add more to the game necessarily, it''s annoying when you can no longer review the information that an NPC has given you when playing a game like an RPG. That''s probably something to keep in mind too.


Yeah, a good journal system is important for many games. There''s little reason why entire conversations can''t be logged in there. Also, an NPC changing what they say doesn''t necessarily have to mean the information is gone forever. It might just be that you get a briefer description the second time around.

quote:
Original post by Ascent
But nothing you mentioned *couldn''t* be addressed.... I guess the question is why don''t more games address those things... which I think is what you asked? ;-)


To be honest, I''m not really interested in debating the current standard of games like many people are. If I cite them, it''s as a point of reference so that people can see what I mean. No amount of complaint on here will change much in the commercial world. So what I am interested in, is showing and developing practical solutions to these problems so that the developers here on Gamedev.net can apply them to their own games.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]
quote:
Original post by ShadowWolf
Well, I think the autocue problem is also a subjective thing. Although it doesn''t add more to the game necessarily, it''s annoying when you can no longer review the information that an NPC has given you when playing a game like an RPG. That''s probably something to keep in mind too.
That''s right. But what is the reason we are missing this important information? This why I sometimes miss important information:
1. I pressed ''X'' (a button to close a dialog window) just 1 milisecond after the window that contains the important information appear. As a result, I would see a ''blink'' on the screen, and I was like "WTF was that?"

Why did I do it? I was going to close the dialog window just before that window. However, due to some reason that I do not know, the dialog window (that I was going to close) autocloses itself and pop a new window (that contains the information). Therefore, instead of closing the window I intended to close, I closed the window I didn''t want to close.

Solution: make it consistent. Give players the control to close every dialog window in your game. Don''t make some dialog windows autoclose themselves.

2. I forget what he said. NPC said something, I was "OK." A second after I was like "what did he say?"

Solution: create a log or some kind of journal that will autorecord every important information that you receive. Wizardry 8 did this quite nicely. Most importantly, let players aware of this journal since early game so they know where to look for when they got lost.



Back on topic, dumb NPCs. I was thinking about this not a while ago, but my primary focus was another symptoms.

It''s so quiet here
This is somewhat related to "Do they have no lives?" symptom. Every RPG, I literally mean every, that I have played haven''t addressed this issue. From the beginning of the game to the end of the game, I keep seeing the very same people wandering the very same town. Some keep saying the very same words, and doing the very same thing. It is a village they said, but I only see 10 people living in that village. Some don''t even move around. When you enter a (the so-called crowded) city, you only see 15 houses. You head to the market, what do you see? Nobody. There are only 5 people around you, and they seem have no purpose being there other than to tell you something about their city. Where is everybody else? What are they doing? The city is dead. Where is the joy of entering a crowded city, people move around, too busy to talk, you hear murmurs all the time, you keep bumping on people. The only RPG I have played that gives me the feeling of entering a ''city'' is only Ishar 2 because they have so many houses (you can''t enter them all) and it''s huge. It feels so different if you just came back from a dungeon, "yes, back to the city." You need a map if you don''t want to get lost. Too bad the only thing it lacks is people.

Solution: create a system that generates a random NPC with random order. This sytem will randomly create an NPC for every x second (depending on how crowded the city is and what time it is), give them a random order (head to the market, go to harbor, go to house X). Don''t allow players to chat with this NPC. Or you can have an ignore level. If it''s above a certain threshold, it will not talk to players at all. This NPC is meant to populace the city and nothing else. So you will have a city that is alive, dynamically changing, and doesn''t look the same as the last time you visit it.
Advertisement
quote:
Original post by Kylotan

Oblivious to danger . Ever played an RPG where, for some reason, a monster has strayed close to town, and is hacking lumps out of you while local farmers mill around as if this is normal and not a threat? I have.
...
Being oblivious to danger should be simple to fix. Most non-player characters in the game will be flagged as either aggressive or peaceful, and peaceful characters should fear aggressive characters of a similar or higher strength level. The action to take to resolve a ''fear'' state should be to run away, which is a simple reverse-pathfinding algorithm. Additionally, aggressive monsters shouldn''t only attack players; they should attack whatever is a valid target, which is probably any other character of a lower strength level than themselves. If you don''t want your key NPCs getting killed this way, flag them as important and have death just knock them unconscious for a bit.



I suggest that each NPC be given a "safe place" or two. A place that, given their character, they might feel safe. This place might be their house or a townhall or the actual town itself (if they''re outside it.) When they run away, they should do one of the following: run to a crowded area; run to their safe place; if that isn''t safe enough, run to the town-specific safe place, or fight. However, a check should be made to make sure they won''t be trying to run through some sort of direct danger... ie the enemy they are running from. In this case they could choose a different safe place or failing that run directly away from the enemy even into a possibly unsafe area (kinda like a person who panics and runs deaper into a jungle.) If they have nowhere to run, they can cower or fight.
quote:
Original post by Kylotan
''The autocue'' . NPCs in many games have scripted lines to deliver hints, plot development, and so on. Sadly, they often repeat the exact same line each time you speak to them, and worse still, 100 different people might say the same thing, with a slight change to the subject matter. How can you believe someone is real when what they say is so obviously scripted?


In most games, in order to talk to NPC, you only need to press a button and the NPC will happily tell you whatever it wants to tell you. In real life, it''s not the same. You need to provide a question if you want to talk to someone and expect something from him. So provide a list of questions that player can choose from. After a question has been asked, remove that question from the list. If the list is empty, player can no longer chat with that NPC.
I''ve thought about this before and decided one solution to the problem is to have a knowledge base. The knowledge base containts all the information local people might know, as well as things people all over would know. There would also be subsets of the knowledge that is limited to certain kinds of people. So if you goto a village and talk to a villager he might talk about the poor harvest, or mention the dragon thats being terrorizing people at the captial. You could even use precepts to have the NPC derive rumors, by combining similar facts in the knowledge base.

Example:
fact1 - A asian man has been staying at the the inn all week.
fact2 - Several Villagers have been found murdered over the last week.

The villager when asked about rumors could combine those two facts together to create "If you ask me the asian man is responsible for the recent murders."



-----------------------------------------------------
Writer, Programer, Cook, I''m a Jack of all Trades
Current Design project
Chaos Factor Design Document

quote:
Original post by TechnoGoth
I've thought about this before and decided one solution to the problem is to have a knowledge base. The knowledge base containts all the information local people might know, as well as things people all over would know. There would also be subsets of the knowledge that is limited to certain kinds of people. So if you goto a village and talk to a villager he might talk about the poor harvest, or mention the dragon thats being terrorizing people at the captial. You could even use precepts to have the NPC derive rumors, by combining similar facts in the knowledge base.

Example:
fact1 - A asian man has been staying at the the inn all week.
fact2 - Several Villagers have been found murdered over the last week.

The villager when asked about rumors could combine those two facts together to create "If you ask me the asian man is responsible for the recent murders."



Nice. You could then modify the knowledge base after certain quests have been completed, like in Kylotan MM6 example goblins in the keep. That way NPCs would adjust accordingly.

[edited by - alnite on February 22, 2004 10:59:37 PM]

This topic is closed to new replies.

Advertisement