   NPC gossip in an RPG (I think I'm on to something really good ;)
  (Sorry for the long post, but I think it''s *really* worth it =P )Hi there. I was browsing the forums and found this thread:http://www.gamedev.net/community/forums/topic.asp?topic_id=77971It''s about making NPCs share knowledge about the world. There are 2 main approaches to this, using semantics networks (which are kinda low-level so they''re really flexible but the generated text looks a lot like "A is B", I''m not saying it''s bad but there is room for some improvement =) and something like using a big list of phrases (knowledge chunks), and each NPC just points to the phrases that it knows (so each piece of knowledge has to be written by the team). Either way allows information to be shared amogst the NPCs and communicating it to the players.Ok, when reading this I thought that the best compromise between these 2 would be something with the complexity of a semantics network, so you can ask the NPC about stuff, and it can relate information, etc, but it should include high-level text (making it less flexible, but computers can''t write as well as humans just yet =PHere''s what I came up with. The knowledge system would be tied closely to the conversation system, but what the heck =) I think that it is able to convey the illusion quite well. There are nodes, pieces of knowledge about anything in the game, that can be events, people, locations... Each one has some text, which is used when NPCs communicate that node (to the players or to each other). But the catch is, this text has some keywords in it - pointers to other nodes - which can be thought of as hypertext links in the internet. To make the text more interesting and varied each node has different names and one is picked randomly and inserted in the text ("the orc", "orcish hordes", "those filthy orc", "monsters", "evil creatures"...). They should also have probabilistic information about how different NPCs would find the information interesting or not (with this simple addition there''s a whole new level of depth in it: you don''t just ask anyone about anything, people usually know more/remember better information about stuff related to their job or location). Ok, here''s a small sample of some nodes:an orc raid: I heard that *the orc* attacked the *town of whatever* about a month ago. They say *lord shibby* was taken hostage during the fight. (general interest: below average; more interesting for inhabitants of town of whatever, fighters and nobles since there was a battle and a noble was kidnapped)the orc/orcish hordes/those filthy orc/monsters/evil creatures: Everyone hates them. They''re just plain evil. It is said that they live in the *western mountains*. (general interest: average, more interesting for fighters)town of whatever/a distant town/a fishing village/one of the empire''s border cities: It''s right south of the other town of whatever. (general interest: low, more interesting for inhabitants of town of whatever and maybe adjacent towns)lord shibby/a local landlord/one of those stuckup nobles: He''s known for being arrogant but also a talented swordsman. He served in the *army* during the *undead wars*. (general interest: low, more interesting for inhabitants of town of whatever and maybe adjacent towns, and nobles)The part that says "about a month ago" should be a special keyword that shows some text based on the time of the knowledge (so time would be a kind of a special variable of the node).An NPC can ask the other about something, and after the other one replies, one of those keywords is chosen at random and a question about that keyword is asked. Players would be free to click whatever keyword they want to know more about. The asking character should say a small phrase like "What can you tell me about [keyword]?", maybe there are different ways of asking things and one is chosen at random, or maybe there are specific questions for different keywords.You can see how meaningful conversations could arise from this simple net. It would be cool to walk around town and see small groups of people talking about the latest attack to the nearby town by a dragon, asking stuff about the dragon, who killed it, where he came from... And it''s not that hard to implement. Maybe there''s more to this... ideas anyone? 
  It seems like a decent start, but I don''t think you''ve considered all of the things you probably want it to do.  For example, how is new information added to the tree when things happen and how does it propagate through the tree?  Secondly, what is this going to accomplish that hasn''t already been done?  This seems very similar to Morrowind''s chat system, though I have no idea how they implemented it.  However, it''s simple and seems like it''ll work fairly well for what it attemps to accomplish.tj963 ;  Hi,I also have read that thread some time ago. I was so impressed by it that even implemented basic news-excange system in my game. Probably it will be enchanched in future (if i'll have time)So a bit about how it is realized at the current moment. When NPC notices a death, a battle or someone breaking the rules (e.g. stealing) he will rememeber about that. When he meets another NPC, they may start talking and exchange news.Of course player also has possibility to ask about news (but there are certain themes about whom NPCs will never speak. For example, noone will tell to player or other NPC about what they have killed - if there will be possibility for NPCs to kill each other. However, they will tell about goblins they have killed, or murders they had witnessed.)The problem is that you need a designer predefined news, but that ruins all the idea of randomness and reality. Or you need a real and persistent world, but that's way too hard to implement. In my game will be realized compromise - there are some designer-defined news and some *real* news, created at runtime.As for "the orc/orcish hordes/those filthy orc/monsters/evil creatures" - it is good idea use simple random number generator here.When player will talk with one npc, the text will be:"I heard that *the orc* attacked the *town of whatever* about a month ago"When he will aproach another, it will say:"I heard that *evil creatures* attacked the *fishing village* about a month ago"This just makes the conversation a bit more realistic.   ___________________________Chaos - open source RPG http://chaosgame.sourceforge.net [edited by - the_prophet on March 7, 2004 2:04:35 PM] [edited by - the_prophet on March 7, 2004 2:06:18 PM];  I've considered that, and it's easy to add low-level information automatically based on a dynamic world (who killed who, what attacked what village, what resources are missing, etc), but it ends there with current technology. And gossip is about a lot more than that. Just like this way you still have to type all the high-level text (something about the orcs, something about the raid...), variety requires that someone be constantly adding new interesting gossip (so you would have knowledge about low-level events in the game generated automatically, the general information on the game world that is like "common sense" knowledge such as something about the orc, and posterior knowledge, probably more volatile, that is added as the game progresses).I don't think this is bad, if you find a small team of people who are interested in writing, they could just play and occasionally write a piece of gossip based on real stuff that happened in the game world. I know that there are a lot of talented people interested on this (the fact that they write whenever they want is a big plus). Wouldn't it be really cool if you traveled to a far away town only to hear the story of how YOU defeated that deamon 2 months ago? [EDIT] I got a bit too carried away so I forgot some stuff =PWell it has all the advantages of a semantics network and NPCs with actual dynamic knowledge. I don't feel like breaking it down to a neat list right now sorry =pthe_prophet, your system sounds like it's really cool. And yes there will always need to be designer-defined stuff. But there's room for improvement (like with keywords so NPCs can have conversations instead of just exchanging arbitrary pieces of information), it would be nice to see a game with a system like this taken to its full potential so I hope you have the time to do it =)   [edited by - Jotaf on March 7, 2004 6:36:18 PM];  Damn, I always have the best ideas when I should be sleeping or studying (in this case, both =)It''s an extension of the previous method I described, but merged with a real semantics network. Actually you don''t have to know any of that to understand how it works  It would be something like this:There''s a list of links. They can connect nouns in a kind of an arbitrary way (for the computer they have no real meaning; but think about it, having a structure saying that "A is B" doesn''t really mean anything to the computer either). Anyways... A link is like a "is" relation between 2 nouns but at a higher level: it can take any number of nouns and has a text connecting them (preferably a text that has randomized parts in it for variety). There could be a link that is a raid story, connecting a number of nouns - the orc or any other monster that attacked the town, the name of the town, who died and who fought like a lion... (there would be different links for different stories)Then there''s a list of nouns. These are players, monsters, towns, anything that can be connected through links. Each one should have many different forms in text, again for variety (like the different names for the orc in the first example).Finally, each NPC has a list of knowledge nodes. Each of them points to a link and the nouns that are related through that link. Now the generic raid can apply to any number of raids that happen in the game. The possibilities are limitless I guess - since each link is extremely abstract, any kind of knowledge can exist in the NPCs'' knowledge bases.But why bother using this system over the other one (or any other one at all)? First, and obviously, links are like templates and can apply to a number of situations. It can be the king who is sick, or the NPC''s mom, or everyone at some town. But this way you can have inference like with real semantics networks (the NPCs can draw logic conclusions!). Since it''s so high-level, it wouldn''t use just boolean logic and stuff like "A is B and B is C so A is C", but it should use some hard-coded (using a scripting system? data files?) inference rules. If you''re serious about this there would have to be a large number of them, but even with a small number, like with a small number of links, you''d get interesting effects. The NPC would try some of these inference rules sometimes when chatting, so most of the time the picked rule doesn''t really apply, but sometimes they WOULD apply and a new piece of knowledge is born. They would look like, "if a town is attacked and the town is near ours, then we could get attacked anytime now!!!" (think about it for a second - see how easy it is to check if this inference is true using this system? =)I''m sorry if there''s a lot of gibberish there and I didn''t explain myself correctly. It''s getting really late and I still have to study for a test... I can be SO lazy sometimes =) ;  This idea was discussed just recently infact in this thread:href="http://www.gamedev.net/community/forums/topic.asp?topic_id=209145">http://www.gamedev.net/community/forums/topic.asp?topic_id=209145   It has some good ideas on how to handle this.   -----------------------------------------------------Writer, Programer, Cook, I''m a Jack of all TradesCurrent Design projectChaos Factor Design Document ;  Yeah I know, I posted there too, I should''ve remembered to have a link to it too in my first post It''s a good thread but everyone seemed to avoid the topic of HOW to implement something like that. (This is Game Design after all  There were lots of good points about semantics nets and stuff like that though. So I felt like this discussion didn''t really fit there =)I''m sure there are better ways of doing it. I just found this one which seems like it might have some potential. Comments? ;quote:Original post by TechnoGoth  This idea was discussed just recently infact in this thread:href="http://www.gamedev.net/community/forums/topic.asp?topic_id=209145">http://www.gamedev.net/community/forums/topic.asp?topic_id=209145   It has some good ideas on how to handle this. fixing your clicky:http://www.gamedev.net/community/forums/topic.asp?topic_id=209145;  I''ve got a proof-of-concept/prototype of a knowledge system like this (actually it''s a bit different, I found a better way of doing this). It works great, it''s able to generate pretty good gossip text, and at the same time it keeps all the data in a structured way so that the player can ask the NPC any questions he/she wants, nitpicking every little detail, and the answers look realistic (the NPC can also tell a story that develops over time, with different "chapters", etc - so with some aditional code it can witness a battle and tell that story in a way that looks pretty cool). I''ve got the short story of the battle and who was taken hostage, plus knowledge about all the involved parties, places, time, etc, packed up in about 30 bytes If I see more people interested in this, maybe I''ll upload the code or something. It''s pretty simple actually. And I''d also like to ask, where is the best place to post this? It''s not really related to AI, is it? Maybe in the "general programming" or "game programming" forums? ;  I am still interested with that. I don''t really expect you to post the source. Just the executable will do just fine for me, as long as you describe the algorithm/method you use. 