Advertisement

Best way of defining NPC behaviour

Started by September 02, 2004 09:52 PM
41 comments, last by C-Junkie 20 years, 4 months ago
Quote:
Original post by Heaven
In other words, keep it simple. Right?

On that note, does anyone plan on actually coding a test bed?

Take care.


I'm always looking to implement my ideas as well as many others... But being able to actually do it is another question ;). I really need to get off some of my current projects and back onto some whacky test-cases again :P
Quote:
Original post by Washu
No real reason to disallow false beliefs. Also, each character should have a database of information that they have heard or otherwise learned about. This information should age, and the older it gets, the harder it is to retrieve from the NPC. This way we can simulate forgetfulnes that results in sparks of inspiration (a conversation triggering a memory)

Ayup. In the implementation I am working on each knowledge has a timestamp, and there are rules on how to "forget" this knowledge. So a NPC observes big treasure, and adds a high fact about it into his knowledge base. with time the knowledge about this treasure goes down again and when it comes to fullfil greed of the NPC, the treasure-knowledge doesn't weight much any more.
-----The scheduled downtime is omitted cause of technical problems.
Advertisement
Quote:
I don't see the problem with "false beliefs" you spoke about.
I don't have a problem with representing false beliefs, but the existence of false beliefs implies that every NPC must then have its own representation of the world. That is a significant amount of data for realistic NPCs.

Maybe the language processing isn't too tough in itself, but working it into one's game engine is also a problem. I figured I'd want something significantly better than adventure game language, and so far as I know, no game has done this yet ie. it probably isn't too easy.

EDIT : Sorry, double post. Can a mod please delete the anonymous post above? Thanks
First, let me say that in my currect project, all my NPCs are given an AI state, whether it be to do nothing or try to kill the player, ... simple stuff.

Defining NPC behavior, I think, should all be a matter of AI; since an NPC *should* be made to replace a PC, it should act like a PC. The problem is, as others have pointed out, that actually realistically programming this is unfeasable.

So we have scripts. In my project, a script consists of an AI state, and several lines of text that the NPC cycles through during user interaction.

Scripts are used to make up where technology fails us. We can't programmically create a perfect player facsimile, so we script a psudo-player who will have certain characteristics of a PC, but will also have certain obvious limitations.

Quote:
Agreed. I mean, if your shop is on fire, you don't just keep on trying to sell your wares.

So from this mindset, we would not allow the shop to catch fire, and if we did, we would already have prepared a script to accommidate this eventuality.

Though I'm not arguing scripts are bad. The problem is, that at some point in the game you will run out of scripts, unless you constantly update them (which, again, is unfeasable), simply because you can't predict every eventuality.

So this is where the AI solution steps in. With AI, whether it be an ANN, or a simple heuristic, (with or without a script) it should preform dynamic actions. I'm not suggesting that we all go out and write (or attempt to) ground breaking MORPG AI that behaves exactly as a human would. No. What I'm saying is have the AI try to play the game as the human plays the game.

For example. In my project, you start out next to a castle with a guard. The guard is friendly, and will talk to you. If you try to assault the guard, he will take on to this, and become unfriendly to protect himself. If his friends in the castle see that their friend outside is getting rough housed, they'll defend him, and so on. The problem is, it is all scripted, and will happen the same way every time you play the game.

I think the solution behind this is genetic algorithms. If you slay the guard, and then the castle garrision comes out, and you slay them and take the castle, then the incident should be recorded, so that when you come to the next castle in the kingdom, they'll wisen up and not open the gates for you.

The key behind this is that you, as a programmer, do not have to anticipate every eventuality. Because, frankly, thats near impossible without making so few options for the player so as to make the game boring. The NPCs themselves would learn from their own mistakes, and build their own database of eventualities, and in this way become "smarter".

And then you can work from there: multiple generations of AI; parents and childern, the genetic inheritance of knowledge, characteristics, etc., so that you could train a system of NPCs to your liking, then lock the databases. Or keep them unlocked.

I've always found that genetic algorithms can often produce strange, but oddly pleasing results.
Quote:
Original post by Spalaen
I don't have a problem with representing false beliefs, but the existence of false beliefs implies that every NPC must then have its own representation of the world. That is a significant amount of data for realistic NPCs.

Not necessary. The same way an NPC can have a false belief, a complete town can fall to the false belief. So if you save knowledge of towns, a complete town has the same belief, no matter if right or wrong.


Quote:
Original post by Mushu
Defining NPC behavior, I think, should all be a matter of AI; since an NPC *should* be made to replace a PC, it should act like a PC. The problem is, as others have pointed out, that actually realistically programming this is unfeasable.

So we have scripts. In my project, a script consists of an AI state, and several lines of text that the NPC cycles through during user interaction.
[...]
So from this mindset, we would not allow the shop to catch fire, and if we did, we would already have prepared a script to accommidate this eventuality.

Errrr....
I can't follow you here. Or I don't want to.
Why you think we HAVE TO use scripts at all? Scripts are exactly the part we don't want to have, as you as developer would have to think about every single situation and put a proper behavior in the script. You wouldn't have any reaction of the NPC that would suprise you, as all and everything is fixed in the script.

Say the shop is on fire, our game engine would hurt the NPC standing in it, and the NPC's behavior is designed NOT to get hurt. So the behavior would lead the NPC out of the shop, no matter WHY he got hurt inside.
You don't have to put in the script:
Shop on fire->leave shop.

What if now the shop starts to break down, the NPC gets hurt again. You don't want to come up with another script section:
Shop breaking down->leave shop.

What you want is to set up a behavior "don't stay on locations you get hurt."
Now every time the game engine hurts the NPC (cause of fire or whatever), the NPC updates his knowledge base to head away from this location.
If you add the ability to set a shop on fire, all you have to do is to update the game engine to hurt characters inside. The behavior model will then take care about this new situation itself.
-----The scheduled downtime is omitted cause of technical problems.
Quote:
The same way an NPC can have a false belief, a complete town can fall to the false belief. So if you save knowledge of towns, a complete town has the same belief, no matter if right or wrong.
That's the obvious solution but I think we lose a bit of realism here without a well-defined system to allow for exceptional cases. And it may also affect adding random variation among the townsfolk. I'm sure it is possible to reduce the complexity of the problem going in the direction you describe, but I'm just saying that it wouldn't be a trivial thing to implement.
Advertisement
Quote:
Original post by Spalaen
Quote:
The same way an NPC can have a false belief, a complete town can fall to the false belief. So if you save knowledge of towns, a complete town has the same belief, no matter if right or wrong.
That's the obvious solution but I think we lose a bit of realism here without a well-defined system to allow for exceptional cases. And it may also affect adding random variation among the townsfolk. I'm sure it is possible to reduce the complexity of the problem going in the direction you describe, but I'm just saying that it wouldn't be a trivial thing to implement.

Actually I have implemented a knowledge system that is capable of both. To fight the memory problems I can set special information to be passed to the town knowledge pool at once, while other information types stick to single characters (this doesn't mean a NPC can't pass his knowledge to other NPCs or to the town pool if he wants so).
This helps to save resources but you still have the alternative to do it the other way
-----The scheduled downtime is omitted cause of technical problems.
Quote:
Original post by Omnibrain
Quote:
Original post by Mushu
Defining NPC behavior, I think, should all be a matter of AI; since an NPC *should* be made to replace a PC, it should act like a PC. The problem is, as others have pointed out, that actually realistically programming this is unfeasable.

So we have scripts. In my project, a script consists of an AI state, and several lines of text that the NPC cycles through during user interaction.
[...]
So from this mindset, we would not allow the shop to catch fire, and if we did, we would already have prepared a script to accommidate this eventuality.

Errrr....
I can't follow you here. Or I don't want to.
Why you think we HAVE TO use scripts at all? Scripts are exactly the part we don't want to have, as you as developer would have to think about every single situation and put a proper behavior in the script. You wouldn't have any reaction of the NPC that would suprise you, as all and everything is fixed in the script.

Quote:
My original post
Though I'm not arguing scripts are bad. The problem is, that at some point in the game you will run out of scripts, unless you constantly update them (which, again, is unfeasable), simply because you can't predict every eventuality.

I agree competely with you. That's why I suggested genetic algorithms [wink]. I just use scripts because they're faster to write (and no training is required!)
Quote:
To fight the memory problems I can set special information to be passed to the town knowledge pool at once, while other information types stick to single characters (this doesn't mean a NPC can't pass his knowledge to other NPCs or to the town pool if he wants so).
Nice! You seem to be pretty far along - do you have a demo film yet?
Quote:
Original post by Spalaen
Nice! You seem to be pretty far along - do you have a demo film yet?

Nothing ready to show publicity. Most about this is printed to the debug screen anyway, and the world is small enough one could say actual behavior is still scripted (But I have the log to check what decision was made because of which need/knowledge).

When our project is heading to beta I will inform you ;)
-----The scheduled downtime is omitted cause of technical problems.

This topic is closed to new replies.

Advertisement