How to make NPC's "gossip"

Started by
66 comments, last by Gollum 21 years, 2 months ago
Hello all, It''s been forever since I was haunting these boards. I gave up on C++/DirectX hell (this was DX 7.1), and was stagnant for a while. But now I have found Python/SDL/PyGame and I''m in heaven. It is SOOOOOO easy. But, I digress. I am working on little proof-of-concept programs for what would be a pretty cool RPG (aren''t they all at the start? ). One of my main ideas is the concept of NPC "gossip". It goes something like this: I hate the RPG phenomenon of going "rumor shopping". That is, I hate going to the tavern to get rumors, talking to everyone there until I''ve gone through all of their built-in phrases, then following each one to some remote location ("Go talk to Ulf, at the Green Dragon Inn, in the town of DarkMoot," etc. etc.) just to complete a built-in quest, to get some money/armor/jewels, and then start the whole thing over again. It''s uninspiring, repetitive, and it doesn''t seem REAL. One of my solutions is to build a world with a working economic model and NPC''s who have goals and needs (yes, I used to hang with Nazrix and co. back in the day, but I had those ideas _before_ I did that. Really. :p ). But on top of that, the NPC''s would travel, and in their travels, when they met other NPC''s, the would share knowledge. In other words, NPC''s might start off with certain built-in knowledge, but gossip would travel as the NPC''s travel. For example. Let''s say that orcs burn the fields of HappyTown. Well, that means no more grain, and no more bread. People start to starve. So all of the people of HappyTown know this is the case. Some of them leave, and in their travels meet others, and share this knowledge. Or maybe a traveler comes through and picks up the gossip. Then, you can hear about this second, third, fourth hand. You can then go to the town, find that, lo and behold, it''s true, and start kicking some orc butt. People see you doing this, and you reputation grows a bit in the immediate area. But your reputation would spread, too. Eventually, after enough orc butt-kicking, orcs have heard about you, and stay out of your way. Or decide to come after you with a vengeance. You can see why this would be so cool. It''s much more natural, believable, and practically infinitely playable (assuming, ahem, a perfect implementation). If you''ve read this far, you''re very patient, and maybe even excited about the possibilities. Here''s what I think would be required for such a module to work: 1. A way for NPC''s to store information. 2. A way for NPC''s to gather new information from their surroundings. 3. A way for NPC''s to gather information from each other. 4. A way for NPC''s to parse their information into realistic conversation with the player (or into newspapers, etc.) What I''m not sure about are steps 1 and 2. I''ve thought about having certain types of objects (tokens?), which can then be modified by adjectives, like so: The ------ is ------- Insert into position 1 the phrase "village of HappyTown". Then it can be modified in various ways: The village of HappyVille is ------- "starving," "at war with ----," "a good place to buy -----," etc, etc. There would be some sort of tree, which would take observations from the surroundings, and figure out what nugget of gossip to create. I suppose I would also have to prune out old gossip, too. I guess I need to create some sort of tree to choose the tokens??? I don''t know. If you have any ideas, or if this has been covered in a thread which I have not yet found, please let me know. - Gollum the longwinded
Advertisement
Ok,
Looking through the archives, I have found a couple of threads which bring up the idea of gossip and how it would improve RPG''s. Unfortunately, most of the posts are just blue-sky ideas which are well-nigh impossible to implement ("What if the NPC was a dwarf, so he thought killing elves was OK, but he didn''t like the PC, so he lied about it, and then since the PC didn''t understand dwarvush very well, it was further garbled...").

Being a staunch realist about my skills, I''m leaning toward having each possible fact live in a data structure (or database), and NPC''s will either have access to the data or not. At this point, they will report it truthfully. If I can get that to work, _then_ I''ll look at having biased NPC''s, "Chinese whispers" where the truth becomes muddled, etc.

I''m still curious as to what would be the most efficient way to build and store the "facts" themselves. Especially whether a big array (list in Python) would be faster or slower than some sort of database (in my case, I''d be using MySQL or Postgres). At some point, an NPC has to go from an event to a description of the event. Or maybe the events build gossip items themselves?

Opinions?

Thanks,
chris



well I''m not an expert at this but =)
what I''d say is this build one centeral database with all the current gossip in it...maybe not as strings but say as structors like this

  struct sGossip{     DWORD ID;     DWORD Subject;     DWORD Verb;     DWORD Noun;};  


then for each thing in your game (or type say orc) asign an ID to you would then put this into Subject... then for the second game object put its id in noun say "HappyTown"... then you would have a list (enum) of verbs "at war" "raid" "killed" ect... for this example we''ll use "raid" so we have "orc raid HappyTown" then you could use a chatterbot (basicaly) to elaberate on this... then for passing info from one NPC to the next just have a list in each npc''s class/struct of DWORDs... then just pass a random ID or two when ever an npc gets with in say 5 feet... to generate new gossip... when ever an PC/NPC performs and action worthy of noting generate a new bit of gossip... then everyone with in visual/hearing range would get the new gossips ID in there lists... for clearing old gossip out ID say maybe expanding the NPC''s gossip list to include a Timestap for when they got it and maybe a decay rate... with each message having its own decay rate for each npc you could bias how long he will rember it and how likly he would tell you about it... O heh one more thing... put a reference counter in the sGossip struct... then for each NPC that knows about it increment it by one... for each npc that forgets decrament it... then when it reachs 0 remove it from the database....


anyways thats my two cents...
The Great Milenko"Don't stick a pretzel up your ass, it might get stuck in there.""Computer Programming is findding the right wrench to hammer in the correct screw."
Use a semantic network! read about them on google and implement one... I did in 20 min...
the problem with this is processing it. to have ur idea work , you would need MANY ncp''s, so thay they can interact with each other and the player in a complex way. the problem with that is processing it - - it would be time consuming. not that that is a problem, but you would be doing lots of processing for the player, and doing mad processing for stuff the player may not even encounter might be a bad thing.
you need to work with assumptions, just make them very complex.
quote:Original post by EvilCrap
the problem with this is processing it... and doing mad processing for stuff the player may not even encounter might be a bad thing

for anyone that is not near the character, you could just update this every game "day" at midnight or something... for people within any given town, just scatter the gossip randomly... and NPCs who travel between towns (if they do) can carry their gossip list to a new town, where you can give it to a few random NPCs there (say, at the inn).

--- krez (krezisback@aol.com)

Edited by - krez on February 2, 2002 6:51:47 PM
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
Yes Gollum, this idea has come up before... there have been several good threads discussing it so I suggest you persist in scouring the archives of this forum.

As a brief reminder to readers about one of the key issues in allowing NPC gossip, you need to consider how information disseminates throughout a collective of communicating agents. Essentially information flow is a diffusive process. I wrote a detailed post about this for a previous thread, so I''m not going to reiterate it in detail here.

Needless to say, you need to limit the temporal memory of NPCs so that they forget some things over time. If you do not, then eventually, everyone knows everything.

The best way to store information is in a central database. This central database works as a knowledge base where each NPC knows (has access to) only a (very) limited portion of the knowledge base. When NPCs converse, they share information so as to expand the overlap between their respective sections of the knowledge base. As NPCs forget things, their access to the KB shrinks.

If an NPC dies then their access to the KB is lost so access to certain pieces of knowledge may be lost. If a piece of information is vital to the game then an oracle could be used to ''plant'' the information in the world somewhere... perhaps a book, or an ancient scroll, or a message from the Gods?

As for how NPCs gather information, you could consider the following: 1) interaction with other NPCs; 2) interaction with the environment; and 3) divine insight! Ignoring the latter, the first is covered by conversation. The second is the most difficult because it implies that NPCs are able to observe their environment and make inferences about it. While this is possible, the computational load is too much for your average computer RPG. I would stick with (1) and (3) as sources of information. Use an oracle to tell NPCs things that you would expect them to know based on their locale and activities.

Finally, you need to consider ''why'' NPCs share information. While a butcher might be prepared to gossip with Mrs Finnigan about the strange death of Mr Obigal''s sheep, I doubt a Master Thief is going to go around freely telling people about the locations of strong-boxes in private homes.

Just food for thought.

Timkin
Hi there,

first of all, great idea. I see a few major problems with this though.

1. An NPC''s knowledge should be limited to prevent NPC''s from becoming "super-knowledgable" after having played for a long time. An NPC could have six memories, for example, and if an NPC learns something new, he should forget his last memory.

2. All the events in the game which can be remembered by NPC''s would have to be clearly defined. They could be stored in a data structure, something like this:

Eventtype | Location | Cause | Interest

The orc raid on Happytown would then look like this:

Eventtype: Raid
Location: Happytown
Cause: Orcs
Interest: 50

Interest could be the probability of NPC''s sharing their information. Unless you want NPC''s to tell you something like this: "Raid, Happytown, Orcs!" The data structure should hold extra grammatical information, to make NPC''s tell their story in correct english.
Whoops, just realized that most of what I said has already been posted. Sorry
Hello all,
Gollum here. Sorry I haven''t replied to any of this; I''ve been sick.
Fist, let me say a couple of things. I''m a newbie as far as programming in C++ or any "deep" language; my area is databases. I''m trying to implement this in Python, so if possible, I''d like code suggestions to be as generalized as possible.
Secondly, I did go back and find a couple of great threads on this subject, which discussed many of my own ideas, and a lot more. Timkin was one of the main contributors.

Here''s what I have done so far:

1. Created a routine to fill a python dictionary (sort of like a hash table?) with gossip items. These are constructed (currently in a random fashion) from what I''m calling "tokens" (see my above post). This will eventually go into a database.

2. My NPC''s are each given two pieces of knowledge. The function could be changed to give more starting knowledge based on intelligence.

3. There is a routine to compare the two NPC''s knowledge lists (arrays for you C people) to see which ones are unique to one NPC, and trade one piece of knowledge to each other.


Very simple, but it works, and I always program incrementally. My next steps will be to have the knowledge transfer randomized a bit, and to only have it happen when the NPC''s run into each other (currently, they don''t live on a map or anything, though I have another prog with maps that I can put them into).


My main ideas now are these:

- The knowledge should be contained in a database. I''m going to have to learn how to interface Python with MySQL.

- I have read (and it makes sense) that if knowledge spreads too easily, it will reach an equilibrium, where everyone will know everything. Different solutions have been proposed for this. One is some sort of "decay function," which would implement memory loss. I have no idea how to write that. Ideas, Timkin? My current plan is pretty simple: Have facts classed in a couple of different ways. One classification will be the type of people who know certain facts. This will usually be by profession. For instance, a baker will never know that the MoorHaven theives'' guild is at 101 Evil Street. So, a baker can''t learn knowledge that is classed as "treacherous," or whatever. The second class would be whether a fact is forgettable or not. Some stuff would be universally unforgettable - no one will forget that a war happened, for instance. Other things will be unforgettable to certain individuals, because they happened locally, or to a member of their family, etc. Then, all of the stuff that _is_ forgettable will be ramdomly pruned every so often. Is that what you mean by decay, Timkin?

- The third point, and maybe most important, is the way I plan to have NPC''s get info from their environment. For the most part, I''m not going to have them do it actively. I''ll have certain types of events (wars, battles, NPC deaths, changes in the price/availability of goods) generate facts through a function. Then, a second function will look through the new facts and decide who gets them. Make sense? Of course, I am miles away from having a working world with events to generate these facts, but give me time ...

- And semantic nets. Guess I''ll hafta go learn ''bout them, too. But learning is what this is all about, after all. Any advice, Puzzler183? Could you post your first semantic network as an example?

Anway, if you guys are interested, espcially you Python people (though the code should be pretty readable by most anybody), I''ll post this once I have random encounters and slightly randomized knowledge transfer ...

Still wanting any ideas,
Gollum

This topic is closed to new replies.

Advertisement