NPC AI in RPG's

Started by
58 comments, last by dwarfsoft 22 years, 10 months ago
Well, if we band together and churn out ideas, then surely we can come up with a compromise that SHOULD work for all RPG''s. Personally I would like to see as many ideas thrown around as possible, because the NPC''s in my game should be able to play the game the way a player would .

When you say deduction based, you are meaning what exactly? That the NPC has some kind of intuition where they "see" more than what is at face value? They understand more about what is going on?

Personally I would like to start off by just having NPC''s that act in a semi-intelligent kind of way. I haven''t seen this yet, but I think it would be quite rewarding .

I was thinking about this a lot last night and I would like for others to add their ideas to this... I think there is a lot that could be milked out of this discussion.



-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
and our eGroup:
http://www.egroups.com/group/dwarfsoft
Advertisement
because the NPC''s in my game should be able to play the game the way a player would

Well, how does a human play a game ?

Archetypical multi-player fantasy CRPG

  • Enter one or several guilds
  • Take quests
  • Take missions
  • Search through dungeons
  • Search character
  • Kill character for a quest / a mission
  • Make friend with other characters
  • Organize expeditions
  • Search information about a particularely tough enemy
  • Search information about artifacts
  • Betray
  • Steal
  • Take revenge
  • If baddie, avoid the police
  • Flee
  • Call the police
  • Hunt for XPs


Achetypical cyber CRPG

  • Create a group
  • Find fixers
  • Find weapon, drugs, software, ... dealer
  • Meet contacts
  • Watch one''s back
  • Wait for a mission
  • Avoid police
  • Exfiltrate
  • Crack & Slash
  • Search information about corporation
  • Search information about person
  • Assassinate
  • Disappear
  • Bribe for protection


Elite-style :

  • Plan trade routes
  • Buy and sell
  • Hire escort
  • Smuggle
  • Carry passengers
  • Be hired as an escort
  • Hunt bounties
  • Escort ships
  • Outfit ship
  • Mine asteroids
  • Engage pirates/Thargoids so as to climb in Elite ranking
  • Do act of piracy
  • Bribe authorities
  • Hunt a ship
  • Take missions for persons / for authorities
  • Explore / go take pictures / ...
  • Change identity
  • Avoid authorities, if necessary
  • Uphold the law ?
  • Answer SOS
  • Emit false SOS


I probably forgot many situations, so let''s call this a beginning. Which ones of these situations can be imitated simply ?

--

As for deduction, I meant that a NPC should be able to infer some information without having explicitely been told it. A simple example would be trying "somebody wants to kill you", "X has been asking for you everywhere", "X has been seen with an enemy of yours" => "X is probably trying to kill you".

Be reading you,
David
Just because it is not obvious does not make it not simple. I can think that a fair number of these could be answered with fairly simple scripting (my scripting language that is ).

Easy is not the the appropriate statement... it is whether or not the results will be what is expected. I will take searching for another NPC as an example here (because that way there is more than one NPC ).

Scripting you could simply have a "command" that states that if an NPC is looking for another NPC/PC then they follow these commands (note that I will not use scripting language, but an english derivative, for ease to understand):

Go to last place seen (if applicable)
Ask people around last place seen
Go to likely spots

If the NPC runs into the other, then the script has a break option.

Hunting for XP doesn''t even need to be covered. This should be built directly into the AI. No adventuring NPC should not do this (that is, if they are a skill based NPC and not a tradesman).

When you say hunting for XP I get the impression of click''n''kill there. I would prefer not to make the XP available only if they hack someone to death. How would a cleric benefit from slashing a few zombies instead of healing others? (This seems to be headed to the "Stop Goblin Genocide" side of things ).

Disappear would be a simple coding of "If you see someone within X area of you, then stick to the shadows and head in the opposite direction". That really isn''t going into much detail, but I can''t think that it would be too hard to code.

I don''t think it is necessary for me to go through each one of these and point out how it could be interpreted so that the NPC''s would behave in a set manner. I am going to get a copy of your list (as a basis) so that I can code in those things that you point out . What I am thinking is that there is a set method for each NPC to follow. You can link all of these actions into a script to follow.

ie.

  • Go search for X
  • If [baddie] Y is around then Evade Y
  • If attacked and Strength < Your strength then kill the bastard else Runnaway!
  • If X is here then greet X
  • If X attacks you then do something


The only thing that I can think of here that is not very explanatory is the "If attacked and str....". In my system, it allows banding of groups and it also allows you to be potentially banded with others, even if (according to the game) you are all just wandering around on the same screen. In this case, the NPC would go: "Strength (and numbers) of all the other Characters on screen against strength (and numbers) of all that I would consider to be friends". This could make for some seriously good betrayal stuff.

NPC''s may think that there are a lot of friends around and one enemy, but the person they trust most stabs them in the back and the rest take that NPC down no problem. The same could be done with PC''s. Just think, they fall in with the wrong croud, and they stumble across some other shady figures, PC attacks thinking that he has backup, NPC''s stab him in the back.... I love it! I am definitely going to have to implement that feature (as a payback for random acts of violence against baddies). If you kill without a reason then the baddies will probably band together to wipe you out. Even if you do have a reason this is likely

================================================

Now to that part about deduction.
How would the NPC know that X has been seen with your enemy?

  1. Has seen X with them (which could work fairly easily)
  2. Has been told that X was with them


It all goes back to Message based my friend . Even if there are more than just message based communications, there still has to be message based com in the game to get to any other advanced topic. Otherwise you can''t model communication amongst NPC''s and if you can''t do that then I would like to see what kind of conversations you would get (as a PC) trying to talk to an NPC!

Simply if there is news that X could be a baddie (from the deduction above) then put them on a "possibly bad" list. When they are approached by X then the NPC should be wary and should be ready for conflict. I can see that this would make game plot and decision making a lot more fun.

Does anybody else wish to add something to this? I am interested to hear more and I am planning on implementing as much of this as I can in MY game



-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
and our eGroup:
http://www.egroups.com/group/dwarfsoft
I just thought I''d post this site if you wanted to see a conversation with a machine. A machine that can really learn what it is talking about .

The url is http://www.generation5.org/iqats.shtml and it shows some really cool language recognition stuff that is relevant to this thread.

This means that NPC''s can "converse" with each other using actual messages and they can understand what each other is saying. I think that this is a little way off for use in games, but it is nice to know that there are people out there who are working on AI that could be implemented in games.

I am sure that this technology runs pathetically slow if implemented in games, but I think there is room for compromise. The game could implement a baby model of the tech and use that.
Some food for thought anyway



-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
and our eGroup:
http://www.egroups.com/group/dwarfsoft
dwarfsoft, finally someone is thinking upon the same lines as I

I couldn''t agree w/ you more about the fact that NPCs should move around, and have an agenda.
In the RPG I''m currently making, I have it so that each NPC has a schedule of where they''re supposed to be at different hours of the day. Plus, that schedule can be changed dynamically as the game progresses.

So, instead of quests and encounters happening at fixed points (like in Baulder''s Gate) they happen more by coincidence as in real life. You may be just walking along and an NPC happens to walk by, and some sort of quest could arise.

I like the idea of NPCs sharing information. That would add a lot of realism.

"The road of excess leads to the palace of wisdom." --William Blake
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
I would like to know how you are implementing your idea, if you have some suggestions then post them here... I am always willing to fight for NPC rights!!!


-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
and our eGroup:
http://www.egroups.com/group/dwarfsoft
quote:Original post by dwarfsoft

We are not here to summon fish.. it just so happened that the thread unraveled that way (no pun intended ).

I don''t know what else I would call Diablo... Slash''n''Hack?
quote]

How about "Chop''em up" :-)




We are their,
"Children of the Free"
Just returning to the topic of communication and information sharing between NPCs...

Take a step back for a moment and look at what will be going on behind the scences of your game. This will help identify key problems that must be addressed and then you can ask yourself, ''Do I have the method to solve this problem'' and ''Do I have the resources to solve this problem''.

First of all, if your agents are communicating and sharing their knowledge, then your society is diffusing information in exactly the same way that smoke diffuses in air, or heat diffuses in metal. What will happen is that if left unchecked, all of your agents will reach the same information state (a type of information equilibrium). Then, talking to one agent will be like talking to them all. Not very interesting.

Secondly, each agents database of knowledge would grow to the equilibrium size. Thats an awful lot of storage space!

You really need to prevent this uncontrolled information dissemination. What methods can you use to do so?

1) Limit the interactions between NPCs.

Unfortunately this simply slows down the rate of information diffusion. The system will still reach equilibrium.

2) Limit the amount of information shared between NPCs (ie only a portion of what they know they communicate during any given interaction).

Again, this only slows down the diffusion. Alternatively, if you prohibit NPC_1 from telling NPC_2 anything other than information_A then the equilibrium information state will contain all of the possible shared knowledge. The rest of the unshared knowledge is not accessible to other NPCs (and is therefore wasted).

3) Limit the memory of NPCs.

NPCs can obtain information but also forget information. By tuning the parameters of such a system you can retard diffusion sufficiently to prevent equilibrium. You must be careful though that your system doesn''t forget crucial information. You can also link the memory length of an NPC to the type of information, the NPCs (or games) current state and/or the sphere of interest of the NPC.

Okay, so here''s me letting out an idea I have been developing for about a year now with a friend. No serious implementation yet so I am happy to let others know. I would love to see this in a game some day and I don''t care if it''s not me that does it!

Rather than have NPCs with individual knowledge bases (data bases) hold all world information in a central database. Each NPC has limited access to this knowledge based on their classification within the world. So for instance a baker would know things about bread, money, buying, selling, food, etc., while a grave-robber knows about death, burial, coffins, digging, loot, etc. Players and NPCs can research information by gaining access to the database in areas they don''t already have access. This is done by interacting with others and swapping information (because they access different portions of the database) or by going to places like the library and reading books!

The benefit of this knowledge system is that it can be extended based on game play. Using standard techniques for knowledge bases, events within the world can be added as knowledge to the database. For instance, player_351 slays Dragon_6. This knowledge is added to the knowledge base and combines with other knowledge (like ''people that kill dragons are heroes'', implying that player_351 is a hero)!

You can then utilise some of the techniques I mentioned above to limit the way the knowledge base evolves. You do have to be very careful that you don''t generate too much information and overwhelm your storage capacity!

Ultimately, you have to ask yourself, ''Do I have the storage and computation resources for this size information project''? Most likely not presently. But that doesn''t mean you shouldn''t develop the idea further!

Cheers,

Tim
Ahh.. It is great to revisit the old favourites

OK - I had an idea similar to this. You have all your world information stored in a single db and then you have variables on the NPCs that dictates what they know (pointers in the database), how well they know it (in a %age of total knowledge) and how quickly they are forgetting it (of the %age). You may also have a maximum and minimum so that they will still remember some after they have forgotten the rest for years

This idea has merrit. You needn''t have a large database to cover a lot of information for a small world. Even if it were going to be considered large, it wouldn''t be more than a few Mb (consider it... "Fish are found in river", "Flour is made from ground Wheat" etc, etc wouldn''t take up much room each ).

Information decay is one of the best things that I can think of for limiting the whole world finding out about everything, and I also think that there is another way to go in this whole issue. Imagine information getting told in a misleading way. An NPC might say something that is confused with something else that they know. It could then occur that a player crossreferences information.

I won''t bother going into the Fishing, Swordfish, Password thing again, but if somebody wants the thing reposted I can always do a search for it. Basically it was one NPC confusing the information that another NPC gave her about two different topics. One was regarding the price of fish at the market, and the other was about the secret password being fish or something like that. Word association and confusing the details is something that could really annoy players, so you would have to have only certain information that could be clouded in this way (a flag that allowed this or not )

Well, that is enough of this rant anyway

-Chris Bennett of Dwarfsoft - The future of RPGs Thanks to all the goblins in the GDCorner niche
I came up with another idea last night while thinking on this topic further. Rather than apply a lifetime to information (implicit memory loss) just limit the db size for the agent, or in the case of a global database, the number of pointers into the db. This size could be different for different agents.

When new information is obtained, if the db or link set is full, then decide which piece of information is the least relevant (to that agent) and discard it or delete the link. This could be the new information just obtained. You could take care of persistant knowledge by flagging it as most relevant (ie never to be deleted).

With this knowledge model the information states of characters would evolve over time and should conceivably be linked to the game state as well!

Tim

This topic is closed to new replies.

Advertisement