Game Development Community

Why yes, NPCs do grow on trees...

by Ted Southard · 01/12/2009 (8:25 pm) · 25 comments

Just a quick update on some procedural content stuff I'm working on.

I wanted a change of pace from going fisticuffs with the engine's swimming functions (the density and buoyancy is driving me absolutely mad), so I figured that I would take a shot at the NPC generator for the game- just as a little proof-of-concept. I figured that it would be a little struggle to get things together, and probably a bear to manage for the in-game version...

Less than 8 man-hours of scripting later, I can generate the following output (it's text because it's describing NPC stats- this is not about character generation or anything graphical):

Basics:
Hiraka Ilar is a male of 44 years of Charkritian descent from Stellar City 
who is a Soldier.

Personality:
Hiraka Ilar has:
 a below average sense of dominance,
 a average level of sensitivity,
 a below average level of altruism,
 a above average level of patience,
 a above average level of stability,
 a low level of trust,
 a low sense of confidence,
 a below average sense of extroversion,
 a above average level of openness,
 and a high level of discipline.

Backstory:
Hiraka Ilar was not sickened by the Pandemic.
Hiraka Ilar's mother died from the Pandemic. Hiraka Ilar's father is dead. 
Hiraka Ilar is an only child. This character's upbringing was pleasant, aside from all the problems.
Hiraka Ilar is not married. Hiraka Ilar has no children.

Vitals:
Hiraka Ilar's health is 884
 Physical Endurance is 666
 Mental Endurance is 668
 Strength is 4
 Agility is 5
 Intelligence is 6
 Charm is 6

Skills:
KB Levels:
1 3 5 12

Nifty, and the best part is that the only part of this that isn't game-ready at all is the "Backstory" part. So the name, vitals, skills (even though I didn't dump them- I couldn't bear doing a billion echo()'s, lol, but there are skill packages that are profession-dependent), and KB Levels are all generated so that they can be fed into the game's DB to generate an NPC. Though the KB Level part, which is used to assign the conversation contexts available to the NPC for the conversation system, is half-done, because I'm trying to decide how I want to determine the knowledge depth of each context (by age, faction, region, most likely some combination, etc). The name generator is production ready for the "Charkritian" faction, with 69706 unique male and 61663 unique female names, excluding the use of middle names (which, if made optional, would boost those numbers up to something like 12 million for male and female each).

NOTE: I just noticed the NPC's Max Physical Endurance amount... Scary, heh ;)

There's a few more things I want to do with this, such as generation of loot, generation of known abilities (probably will do that dependent on skill levels/faction/profession), and of course the DB serialization function- which is basically just an NPC loading function done in reverse. And the hardest part: Fleshing out the "Backstory" part and pushing that into the DB as a "self-context" for the conversation system. It's not high-priority compared with the rest, but I think it would add a lot of character to the world if generated NPCs can be asked about their life and times before the point of time where the gameworld starts. It does become more important though when you get into mission/situation generation and the NPCs need to have motivations besides just being "aggro'ed" by the player.

All in all, I'm very pleasantly surprised by this little experiment, so I'm definitely going to try to drive the rest of these features home and then generalize the namespace for use by the game in a more automated fashion for the mission generation system.

Also, I think that this procedural content generation stuff is a good deal easier than people think it is. You don't need to know fractals or anything wild to do something like this. Just a lot of randInRange() calls and table lookups. As a matter of fact, Anarchy Online does a good deal of procedural content generation now, and within gameplay-contexts that make it very easy for players to accept. This is the direction that MMO content will be headed in very soon (or already has, in the case of an indie MMO or two I know of floating around this community other than my own), as user populations increase and it becomes increasingly expensive to write prose for fed-ex quests.

Not that human-writing doesn't have its place- it most definitely does. But as your requirements for content go up, so does the costs associated with hiring more and more writers. And those writers, however good they may be, should not be aimed at the million small quests you want players to experience 99% of the time. It's probably better, from both a quality and cost perspective, in the long-run to get these writers to create discrete "chunks" of story and dialog that are generic enough to be mixed and matched into generated story-arcs and conversation "contexts" which can be reused. And in this way, you get to generate your missions, and do so with better quality writing since you're not making your writer write fifty variations of the same quest him- or herself.

I know there's resistance to the idea, and like all things, it's not a one-size-fits-all solution, but when done right and in the proper contexts, I do believe that it can really help fill up a world with higher-quality content.
Page «Previous 1 2
#1
01/12/2009 (8:41 pm)
Sounds like a great idea for more minor characters. I like the idea of a generated background story as well. It would be awesome if with each line of backstory generated you could tie in one or several flags on the character that would change their behaviors not just in conversation, but out. For example, if a character's parents were killed by Bandit Group A. Than that would add members of Bandit Group A to that NPC's kill-on-sight list (or their run-away-and-cry list :-) )
#2
01/12/2009 (8:48 pm)
good work!
#3
01/12/2009 (9:05 pm)
It would be awesome to see some missions created with this and the random dungeon generator that is currently under dev, or the one you mentioned you had previously created.

Never play the same level twice!
#4
01/12/2009 (9:59 pm)
Edit: Situation resolved.
#5
01/12/2009 (10:08 pm)
@Patrick: You mean mixing it with features that look like this?

www.digitalflux.com/images/playfield01.jpg
www.digitalflux.com/images/taskgen.jpg
www.digitalflux.com/images/mapgen01.jpg
www.digitalflux.com/images/mapgen11.jpg
That was all 2004 and 2005... I have better tricks to try now ;) If I can pull it all off correctly, it'll be very interesting...
#6
01/12/2009 (10:18 pm)
@Ted, Welcome buddy! Please don't hurt me...
#7
01/12/2009 (10:27 pm)
allways a pleasure to read your progress Ted, and nice work there...
#8
01/12/2009 (10:27 pm)
Edit: Situation resolved.
#9
01/12/2009 (10:33 pm)
@Christian: Thanks! I wish there were a lot more work going on publicly, since it's an area that could use the sort of boost that most of the rest of game development has received from discussion in forums and such. Still, it's really nice to see what a few random numbers can do.
#10
01/12/2009 (10:37 pm)
Quote:
Hiraka Ilar's mother died from the Pandemic. Hiraka Ilar's father is dead.
Hiraka Ilar is an only child. This character's upbringing was pleasant, aside from all the problems.

Wow, sounds like fun - aside from all the "problems".

That made me laugh. :) Sorry about that.

This is really cool! I've been looking into dynamic story generation myself, though only poking the surface for now. I wonder if it'd be possible to generate and regenerate stories in a way that'd disguise the writer's true identity - being a program - from the player.
#11
01/12/2009 (10:43 pm)
@Ted,

I read this blog and I thought, man it would be cool to have a mission with randomly generated NPC's and randomly generated terrain/dungeons. I went to dig for the link to the current random dungeon generator effort and there you were, 4th post down...

Quote:@Patrick: You mean mixing it with features that look like this?
Yes, I think it would be really interesting to extend your random generator to interact with the random dungeon generator work you showed above. The player could enter a dungeon and it will be physically different and populated with different NPC's each time. (This example, the NPC would probably best be served as enemies).

`Patrick
#12
01/12/2009 (11:28 pm)
@Patrick: Yeah, there's a few guys in that thread doing good work on this stuff. I've sort of let it languish for a few years while I researched the NPC conversation stuff, but it's still on my mind. The deciding factor will be what my project needs in terms of asset generation, which will dictate what I develop next.

While Anarchy Online relies on instanced dungeons very heavily for their mission generation, my game is looking to be quite a bit more out in the open. That's what draws me to "softer" content generation like the NPC stuff. You can fade these NPCs in and out of the gameworld when spawning and unspawning (or dying) like actors entering and exiting a stage. The harder part will be getting the AI to be able to work the same way. The personality part of it is in that dump already, and gets affected by all everything from faction and profession to individual regions, gender, and age. But the creation of NPCs that are realistic and can do the job will probably take a good bit of playtesting.
#13
01/13/2009 (6:27 pm)
I nominate this post for best title ever ;) As well as best quote, for the part Konrad mentioned.

A random-anything-generator is something I've wondered about for some game ideas. Do you generate everything independently? Or are personality traits based on background, for example?
#14
01/13/2009 (6:59 pm)
@Daniel: The Personality Traits are influenced by Faction, Age, Gender, Profession, and once I get the tables in the DB done, Region. I'm leaning towards a "literary character" approach to NPCs, so there is some "flavor" introduced to each area. It's not a huge change in people from zone to zone, but you're just more likely to run into people "like that" in certain areas. Some remote areas, for example, will have quieter people with a more wary approach to strangers and more resilience to hard lives, somewhat like in real life.

Of course in real life it's way more complex and there's a million exceptions to every rule, but that just muddies the waters here- and they're muddy enough ;)

What I eventually want to do is have templates for the personality types and use the templates as a default, which can bring a more solid idea of NPCs through the regions rather than the more cookie-cutting approach of just modding middle-of-the-road values that happens now. But before I do that, I need to get the whole AI system up.
#15
01/13/2009 (7:05 pm)
I give a lot of thought on my commute to procedural content generation! I love the inroads you're making here and encourage you to keep on with it!
#16
01/13/2009 (7:15 pm)
@Dave: Thanks. Just trying not to drive myself crazy with the name generators ;) Thinking up 225 male, 225 female, and 350 last names for each faction chips away at my sanity point, lol... But that's really what it is: Lots of lists. Region lists, with lists of conversation contexts. Profession lists with the same. Same for Faction. Then name lists by faction. I'm going to write an item tool so that stuff can be populated easier than the hand-entries I avoid so much, same with abilities. Conversation dialog is designed in the same way, except "chunked" by context and tagged for use in the conversation system (instead of throwing walls of text, you have the NPC talk to the player in a slightly more natural way).

You can look at all that and say "damn, that's too much to be writing", but then if you turn that angle a bit and look at a regular MMO, you'll see they have hundreds of named NPCs, all kinds of written dialog, and naturally need regions and professions listed for the DB backend. The difference is that I'm cutting out the repetition with the generator by making everything a component instead of making everything said independent from each other as in traditional MMOs. The savings are offset by the work done on the generators themselves, but that work is in turn offset by the fact that the generators can keep generating this stuff, reusing the lists you give it.
#17
01/13/2009 (7:20 pm)
@ted

Been reading this with quite a bit of interest.

Regarding name lists, have you considered decomposing your names into a rule system for how names are built up. Inventory the phonetics, and where those phonemes appear in a given name. That way you can build a much greater number of names, on the fly -- provided you didn't already build out the entire combination set by hand.
#18
01/13/2009 (7:38 pm)
Quote:have you considered decomposing your names into a rule system for how names are built up

A few times, actually. I usually forget, then remember it when I'm sitting in front of Excel trying to resist the urge to plunge my mechanical pencil into both my eyes, lol. It's a great idea, and I probably should invest in it at least just to aid me in hand-building the lists, and I'll explain that: You see, when I do the names, there's a bit of "cultural overlap" in them, sort of how Tolkein had six names for everyone, and as you moved from place to place the names would change slightly. So I flip back and forth every once in a while and either carry over a name whole (if the factions were related closely in the past), or I'll modify the names to be somewhat in between. Then again, if I make the name generator snazzy enough, it can do that for me automatically.

And that's also how I start my "namebooks": I start with a map, come up with names there, and those half-dozen or so names act as a template for the rest of the faction.
#19
01/13/2009 (7:41 pm)
Sounds neat, and definitely can be handled by rule sets. For instance, the morpheme '-lai-' in AreaB could be replaced by '-la-' when you move to AreaN.

Alternately, you build a root name, and run morphing rules/aggregate tokens, to handle spatial/historical context. Much harder but allows logical historical names to be produced as well.
#20
01/13/2009 (7:45 pm)
Yeah, sort of like doing a lerp() between names, with the lerp being a possibility of the name sounding more like one culture than another. I think I might do that...
Page «Previous 1 2