Friday, December 21, 2018

Back-end RPG NPC relationship engine

In RPG games one of the major concepts is interacting with Non-Player Characters (NPC) as they hold the information, background and personal viewpoints necessary to flesh out a game world.  As they are vital to RPGs as more than just background but individuals who have things that need to be done (for or to them), the depth of a game hinges on these individuals.  To be sure they are pre-scripted instances of individuals in a game world so that their interactions have a definition to them, be it from the lowly thief you apprehend as a player to a merchant to the most powerful beings in the game world.  At the start of RPGs these were relatively simple and static individuals, and to this day that remains largely true as few people want to find out the backstory and life of the local rug merchant.  Yet that lowly rug merchant, if it is someone that has a script for interacting with the Player Character (PC) is probably important in some way, shape or form as it costs money to script in interactions and then voice the lines for that NPC.  In this way two forms of world design NPC types are described:  static and reactive.

Static NPCs are those that never change and only serve a singular function, like a general store merchant.

Reactive NPCs are the majority of all NPCs in a game world as they react to the player and what they are currently doing.

After gaming moved form a simple dungeon crawl to a larger world setting, the variety of NPCs within those categories proliferated, but the categories remained.  To be sure a number of NPCs started to get a backstory to them, and become fleshed out beyond their current task or role in life.  Yet those NPCs are limited to just that script, and no matter how well and deep the story goes, it will not vary from the internal necessities of the events surrounding that script.  In the Open World RPG genre, that is large and wide-ranging maps and things to do, these types of NPCs started to increase so that the Open World could contain many smaller stories.  As these stories proliferated and a few game designers made events in a very few of them loosely (or tightly) linked, players and reviewers started to get an idea that these were 'living worlds'.  Give an NPC a schedule, a few things to say to other NPCs in a pseudo-conversation, and then add in side-quests: all of that started to bring these worlds 'alive'.  That is the state of the art as it is today, and it is moving in multiple directions with highly branched stories based on what a PC does or doesn't do, so as to yield many different, though definable states and end-states to a game.

In playing a game like The Witcher 3: Wild Hunt (TW3) and going into any small town or village, there are enough NPCs that the player can interact with through Geralt so as to give the feel of a 'living' world.  Yet these are highly reactive NPCs with only a very few of them gaining triggers to advance their script if the player does something that keys that trigger.  While that is seen as 'proactive' and good game design it is still, at heart, reactive in nature.  It can be very complex, true, with multiple differences due to complexities, but those are all pre-defined for the scenarios they invoke.  What TW3 and a few other RPGs miss out on is the individuals that are ones with limited scripting or no way to interact with at all.  There is nothing worse than a vendor hawking their wares to the PC, going over and finding out that it is impossible to interact with them as merchants (or any equivalent).  So a large city with many NPCs that are wandering around have a very few that the PC is allowed to have a dialogue with: this is hailed as an advancement in world design, instead of just very good set dressing.  As the typical game pointed to as 'a living world', it isn't: it is a reactive NPC world design with a lot of set dressing to make if feel more alive than it actually is.

Instead of aiming for a 'Living World' which may be impossible to do given the state of the art for programming, it should be possible to create a Pseudo-Living Open World by using concepts presented in another genre, entirely, which is the Grand Strategy genre as instanced by Paradox Games.  Of most interest to RPG fans is the blending over of Grand Strategy into RPG as seen in Crusader Kings 2 (CK2) and, to a lesser extent, Stellaris (to name just a couple of games I've played).   By the old tradition of RPGs, a character is required to have stats and their actions have an impact on the game world.  In addition they may have skills, abilities, or other powers that are manifested on their character sheet, that the player can use to advance their cause.  These are all hallmarks of CK2.  Now it isn't a traditional RPG, to be sure, as it gives a map, a control screen and pops up events and dialogues that the character has done outside of the player's control: the player has broad control of their character, but not fine control on everything they do.  Set an amition and aspect, and those play with the skills and traits, along with the culture, religion, and any secret society to yield outcomes. What the player only realizes through game play is that this is done with all of the NPCs in the game in the background, as well.  They pick up rivalries, addictions, change their religions or even take the initiative to go against the ruling regime.  All of these are pre-scripted events, but they require no interaction with the player until the player sees them.  With added background complexity due to the sheer number of pre-scripted events that play out between NPCs, the game world is no longer highly scripted towards outcomes: it is scripted to the outcomes of interaction that are randomized to a degree as no individual is exactly the same in any game start.

Interactive NPCs are defined by not being solely static or reactive, but have goals set by character traits, skills, associations and backgrounds, with each of those leading to goal-driven ends.  In CK2 the goals of NPCs (and even the general one for the PC) is given by their Ambition, which is a life goal they set for themselves.  For PCs this can start at the lowest level of 'Make a Friend' or 'Acquire a Title' and scale through 'Acquiring a War Chest', become a Duke/Duchess/King/Queen to 'Become a Paragon Among Men'.  Getting Married, Grooming an Heir and all sorts of other goal oriented activities come under this general category (like Renounce Anger or other such things for Eastern cultures) and many NPCs have them as well.  Look up the NPC chart for the entire game and the slot for an Ambition shows who has which Ambition at any given moment.  Once an Ambition is fulfilled then the individual stands to gain Prestige, Piety, or simple Gold, which is part of the reason that the Ambition was started in the first place.

What is even more interesting is that the vast majority of NPCs do NOT have an Ambition.  The character trait 'Content' still allows for Ambitions to be chosen, but they tend to steer away from acquiring power (though not always) and towards other goals that don't involve power directly.  Ambitions set goals for activities, and those activities then drive the pre-scripted event paths.  Someone intent on becoming a renowned duellist will tend to have that activity or training for that activity high on their agenda.  Someone looking to get married may choose a temporary trait known as a Focus which allows a character to gain a temporary stat boost and other perks when on that Focus, and have events be centered around it, as well.  Thus someone looking to get married might choose Carousing or Seduction, while someone looking to become a Paragon Among Men might choose Scholarship or Theology.  Statistics, traits, background, and what other forms of advancement for a character that are available, like Secret Societies, can drive Ambition (and vice-versa for Secret Societies), and that then creates a Focus swap to enable doing the things necessary to achieve that Ambition easier.  Not easy, mind you, but easier: even the simple 'Make a Friend' can be a very, very hard thing to do.

What this sort of character system creates is not just a Pseudo-Living world but something that RPG makers have been trying to create for decades: Emergent Storytelling.  The means to create this is an NPC back-engine that examines the individual traits, position in life and everything else that an NPC has and then creates the opportunity for an Ambition, changing a Focus and then using means to implement that Ambition.  The beauty of such a back-end to RPGs is that it then puts into play a world in which every NPC can have their own pseudo-life that has activities and interactions based on their own, individual character lay-out.  Everyone takes part in this and only when a PC goes into a general vicinity does this get put into a local instance of interactions.  NPCs for that area are put into play given what they have been doing, what they are looking to do, who they know, who they are associated with and what they hope to achieve.  A schedule is thrown around a job along with those functions and then the NPCs are set off the moment the PC comes into the region of activation for those NPCs.  At that point they follow standard scripting for what they are doing and if the PC never interacts with them, then the most the NPC would get is a change in their record if they happened to see or otherwise know about the PC being there.  That knowledge can be passed on, though it is likely to be removed if there is no interest in the PC.  Actual dialogue and active interaction, however, is stored per NPC, and it doesn't have to be detailed, just a set of flagged fields with a timestamp to record what the conversation was about.  From those interactions there is the possibility that what is chosen for that NPC will change, though that is based on the prior Ambitions or goals the NPC had.  Most NPCs will not have much interest in the PC, and just go about their scripted events without ever being influenced directly by the PC.  With that said, the more people the PC interacts with then the greater the possibility for change there will be.

Why is this important?  First it removes the Static NPC and relegates those to vending machines (unless those become actors, as well, then they will record the interactions).  Secondly it can create the next type of NPC.

Proactive NPCs are those NPCs that have either heard about the activities of the PC, had direct interaction with the PC, or otherwise have the PC come to their attention, AND the PC fits an Ambition equivalent for that NPC and may be seen as a way to achieve it.  Thus the scripts are now altered to that of seeking out the PC (either as a major or minor goal) to seek help in achieving that Ambition.  Based on past activities, reputation with various groups, membership in groups, types of work that is done will all serve as building points for a trigger to approach the PC.  With that said this is not limited to just the PC, but happens among NPCs, as well.  All the NPC to NPC interactions generally happen in the background and the player never sees them, and most will be done as calculations during times the PC isn't all that active.

What comes out of this is individuals shifting routines, seeking new jobs, or generally no longer in a pre-scripted rut as the game world is now not just reactive to the PC but shifts in tone and tenor that isn't reflected directly on the PC but in the game world.  This moves beyond the simplistic moral systems of past games and institutes a world that will take notice of the PC if they are doing something worth noticing.  How a player approaches not just their PC's goals (as given by their own agenda of items that start the game) but can then start to see if there are other things to do in the game world that will offer different goals more to their liking.  A larger story-arc can still be fit in this, but it should be noted that following it is no longer a set path.  Indeed any path the player chooses to pursue that story-arc, even ignoring it entirely, is valid and the story is not pushed in the player's face when they aren't doing anything about it.  A good game design would have other goals, objectives and concepts for play in mind so that something that may be a simple 'go for this, do that' mission or side quest can become the main focus of the game as the original story is abandoned.  These types of story require someone competent and capable as a game designer to put in and realize that what they are offering opens a new way of approaching the entire game.

As an example is Fallout 4 (FO4) in which the main mission of finding your infant son is quickly ditched to do a myriad of other things.  These other things tend to be the bulk of the content in the game and much of it is far more polished than the main story.  An example is the Cabot House side-quest, and working for the Cabot family to do a couple of odd jobs and then get put into the position of trying to figure out what to do with Lorenzo Cabot.  The warnings from his son is that Lorenzo has been totally consumed by a form of alien power and that he has become a monster: releasing him into the wasteland will make the world far, far worse off than if he dies.  If you help get him killed you get one of the most unique weapons in the game.  If you help Lorenzo, however, then for his family it is a disaster.  But after that?  No follow-up.  The man acts like a possessed power-hungry individual, but gets all calm and quiet after having his family killed and gives you a dose of powerful anti-radiation meds once a week.  That's it.  Yet everything about the quest says that releasing Lorenzo will start the coming of a new ending for the world, one that it might take the combined forces of everyone in the Commonwealth to stop, if they can pull their collective acts together.  Not delivering on that particular quest ending is not just anti-climactic, but a pure let down for the player seeking to achieve empowering chaos.  While not a bad quest, it is not well integrated into the game and the transformational nature of that one end branch have no carry through.  The reward for actual role playing is denied: the player is cheated of helping what should be someone far worse than The Master by being his second in command for a conquest of the wasteland.

Another example, actually multiples of them, are in TW3, especially with those women looking to get ahead in life.  To a woman warrior you can best who stays alone because there are no worthy men on the small island she lives on, there is no way to invite her to come along with you as you adventure onwards.  Helping her get a real husband that will satisfy her needs is a far, far better ending to the quest than just bedding her for a night and then offering advice to just get off the island.  She has combat training, is a decent fighter, knows local lore pretty well and otherwise would be a good teammate: at the rate Geralt goes through equipment, giving her hand-me-downs would tend to keep her alive in combat and effective for a longer period of time.  Another instance is Shani, the cute doctor from a prior part of the franchise, reprising her role and serving as an army physician because its what is required of her.  By the end of the game Geralt is well enough set-up to offer her a better arrangement in another land in which her medical skills will always be needed by the Knights of the realm.  Beyond that she could even start to figure out the experiments that were done by an individual looking to cure Witchers.  Then there are the various prostitutes that can be hired and a few have interesting ideas for what they want to do in life, and yet Geralt can offer help to NONE OF THEM.

The potential for NPC stories that are generated on the fly are numerous, and all of them fit around an Ambition or goal, with NPCs using a Focus on a certain set of means to achieve it.  And as for the vendors tending their wares in the market?  Hope you can find the one who is willing to actually trade with you, for as much as the others hawk their wares at you, they don't seem to be able to recognize when you want to buy from them.  This does require game designers to be far more open about the potential of non-main stories and their potential to be not only involving but game changing.  Forging ahead with a main story plot with side-branches and alternative endings is imperative for the overall software project goals for a game.  Allowing potential game changing branches to be examined after the majority of work is done on the main story then requires adapting parts or all of the main story to the new branch.  Minor branching for non-impacting stories will still be the vast majority of what Proactive NPCs deliver: they are not involved with the main story directly, though they may get involved in it if the player lets them know what else they are doing via the PC.  This creates a new environment for game play and story telling.

Emergent Storytelling is utilizing the general concept of Emergence, in which many small activities that are isolated from each other are put together to form a system that has more characteristics than all the separate pieces combined.  In gaming terms this requires those writing stories and scripts for games to include stories that can be generated by the activities of NPCs as they interact with each other in the larger game world.  This does not need to be a complex set of stories, however, and the adding of equivalents of Ambitions (goals), Focus (a larger scale methodology), and traits ( characteristics that reflect viable life goals) in a game for NPCs and then giving interactivity with the larger game world setting as a primary game design tool is the means to instantiate such those stories.

A city never sleeps and so it is with a game world that, from the moment the player steps into it, will begin to change and adapt internally to the changes happening in the larger world, itself.  The player via the PC will have some goal or goals to achieve, or some set of cascading goals that do have a set of predetermined outcomes, but the path to actually achieving the desired outcomes is highly variable.  In fact, beyond a few key individuals or necessary information in set locations, there doesn't need to be much in the way of story scripting: the pathways to those individuals or information or end-goal is something that is created by the interactions of all the NPCs in the game world.  Who knows the individual or information or end-goal can have a few individuals with scripts attached to them and a known set of associates so that there is likely to be a few viable paths (unless some of those individuals get killed, but more on that later) at the game start.  The objective of finding those individuals and getting that connection information is then left up to the player who will then utilize the shifting landscape of NPC associations and Friend of a Friend (FOAF) networks to attempt to find viable connections to their objectives.

A game world like this is highly probabilistic in nature as it requires some random and semi-random internals that are not fixed to allow the player to achieve their ends.  Such a world will get rivalries between individuals as well as closer associations, and that means that some interactions will lead to a lethal end for some individuals.  A requirement of such a world is NOT making a character, any character, 'essential' which means undying by any and all means as they are required for the plot of the story to move forward.  This then requires good game design to leave behind information or hints of where to continue even if an individual dies or is killed.

Individuals who are part of larger organizations will have someone put in their place in their organization from the ranks of those within it.  Those individuals most likely have no personal stake in information sought by the player and may yield up what their predecessor had with little or no resistance at all.  Similarly doing forensics, getting to where the deceased NPC lived or contacting their prior friends and associates is also a viable way forward to get vital information.  All of this may boil down to just getting the information via diaries, journals or just talking with individuals who knew the deceased so as to continue the main story.  In a world in which death stalks everyone, no one is safe, and telling a story in such a game world is a decided challenge to the game developer and makers: their talents, skills and abilities are crucial in creating such a dynamic world and telling a story in it.

What this does for the RPG genre is move it from the deeply scripted story telling of the past and creates a new venue for stories to be told that are not set in stone and in constant flux.  That can be so overwhelming in story creation for Proactive NPCs that the main point of game design may shift from just the player's story and to those smaller stories that are created by the NPCs.  With that said the lesson from CK2 is to be remembered: the vast majority of individuals in the game have no larger life goals and have already found a comfortable place for themselves.

One artifact of such a world comes into play, and that is replacement NPCs for those who have perished.  This requires that a new character be spawned into the world to fit some vital game world function.  In CK2 these are Courtiers, members of PC and NPC Courts, which translates into the larger power and association systems in other games.  Companies are always getting new talent as individuals advance up the company tree.  Religions and other organizations are always seeking new recruits or faithful.  It doesn't mean that such individuals will always be found and in game design terms there needs to be some critical threshold for spawning in replacement NPCs that is determined for all the higher level organization structures that are part of the core game mechanics of running the Emergent Storytelling system.

Replacement NPCs can be targeted for when they arrive, of course, as it is 'behind the scenes' work for the game engine, although a place for that NPC to 'fit in' must also be determined so that such individuals have a place to stay and start processing what their individual goals are beyond the immediate reason they were spawned in.  NPC loyalty to any individual or organization is a simple record that has adjustments to it based on their internal traits, goals and interactions with other NPCs: the new NPC spawned in will have to start trying to fit into the world, unless they are chronically shy or not having much in the way of outward interests.  As it is all the NPCs that a player cannot interact with fall into this last category in standard game design, and this is what Emergent Storytelling is removing as a primary goal.

The expectation for such a game world with these design concepts is that they will tend to be smaller and not Open World in scale when first implemented.  A 3D RPG with stats, skills, traits, and goals for every individual will be hard to craft even with a small set of NPC goals, objectives and means to achieve such.  Failsafe story design requires much thought and work by game designers and not just for the PC's story but for Emergent stories with NPCs.  The overwhelming majority of those stories, in fact perhaps 95% or more will never be encountered by via the PC and that is not the goal.  The goal is to achieve a world that has depth and a vibrant feel to it, and to shift the main story pathways away from highly deterministic design.  What this requires is that storytellers let go of some vital assets at the lower tier of stories, which are the characters who introduce the story and hold key information to continue on a predetermined path to the story conclusion.

Generalized Game Design is the instantiation of Emergent Storytelling environments, in which the challenge is to design a good game world with many smaller stories in it, that then has a naturally fitting larger story within it that is then told via game play.  Seeding a world with a few individuals who have key information is necessary, yet the game designers must also attend to the game world creating new ways to get information to the player that is outside of those seeded individuals as they are mortal.  The old adage rings true in this sort of game design: it isn't what you know but who you know that is important.  Therefore story imperative NPCs will have a coterie of friends and associates who have some reason to know them, although the rest of their lives can be as detailed as the game designer wishes.  Once all the wheels are in place, however, what any single NPC (be they story imperative or not) will do is something that can only be sketched in via an adaptive schedule.  That sort of schedule should have a master template (or calendar) that is then given important change data for each NPC.  It is possible for NPCs to change their master template and then have to adjust the change data for future events to it: master templates are, themselves, unchanged, but can be swapped out and adapted by NPC use for their own purposes.  Thus while a 'merchant schedule' will tend to have the same considerations, some individuals using it will do a time shift for a different shift, and that change is recorded personally.  Other individuals will have less highly scripted schedules and may have ones that are determined on a temporary basis on just a daily waking/sleeping schedule so that their goals and skills fill in the blanks during the day.

Information Discovery on the part of the player via the PC will not, of necessity, follow any pre-made script as that is part of the point of Emergent Storytelling.  There may be a few failsafe pathways put in at the start of the game, yes, but that is no insurance that those individuals will actually be in the world when the player discovers that they were a key link.  Game designers will then need to ask themselves if a given individual they are fond of, that they may have taken time to handcraft, is really all that important to the overall story?  Not every game nor every life ends in a triumphant climax of success, and being successful may often be anti-climactic in nature if one of the key movers for the original story has perished.  This can be artificially shifted, of course, via many game world appropriate means such as resurrecting the dead, making the antagonist non-human, or putting a small organization together that is undying (an incorporated 'individual' as opposed to a corporeal one) that can change out individuals at the top but the goal always remains the same.

The tools of the player via the PC will need to be appropriate to multiple ways of discovery, so that there are more than enough ways to go forward that require no single set of skills or abilities to complete.  A player must be able to augment their lacks either via equipment, social engineering or perseverance  of research.  Not every thug on the street will know what you need to find out, but if the player widely canvasses the game world they will, finally, find someone with such information.  Similarly searching through records archives is tedious, but will yield results either through deductive or inductive logic.  Going from social gathering to social gathering via the FOAF network will similarly yield results, but it may take a long time.  In the more 'brute force' approaches the player also builds up their own storehouse of information and contacts, even if it is outlining the FOAF networks of other individuals.  This is what is known as Role Playing.

Games in the past would use very well scripted and plotted paths so as to present a seemingly endless number of choices.  Each choice leads to a pathway and each pathway must be plotted out via connecting the results to the next logical event.  This will go on in an Emergent Story environment, as well, as the necessary dialogue for correct and incorrect choices for every NPC that can be involved in the main story must be available.  There are, however, no 'correct' paths as players with a few good skills or abilities may be able to pinball between pathways if they find a coherent arrangement of circumstances that allows for either inductive or deductive logic to demonstrate to themselves that seemingly unconnected people and events are connect.

Tracking down suppositions, going down dead-ends or re-opening a dead end with new information from a different source is part of what Detective Games should offer (and often don't) and are an explicit part of Role Playing Games as that is not only a viable Role but a necessary part of the player's own mental toolkit for approaching problems.  Presenting inductive or deductive evidence to an NPC requires the game designers to put in much forethought on the story they wish to tell, especially when it happens in a non-linear Emergent Storytelling world with Proactive NPCs.  This does not require tools for attempting to storyboard such ideas in the game, itself, though it might be handy.

The sheer amount of information that has to be gathered, sorted and then put together for the player may be a daunting task, and the game world will be forthcoming with a vast amount of non-story important data (though may have important information for other stories, social settings or other groups in the world).  Getting anything done in such a game world is a daunting task for the game designer and player, both, as it requires a good knowledge of the fundamentals of the setting and individuals involved in the game world.  Tools for tracking, sorting and otherwise giving a level to such information on its reliability would be a good thing for such a world, though just letting the player figure it out may be preferred to remove hand-holding: anyone taking up such a game will either have an adaptable mental capability for such worlds or not, with the latter being left confused by the non-traditional gaming structure.  This is what happens when RPGs move from scripted, set stories in a reactive or static environment and move to a proactive environment with emergence for stories.

The end result is that on a larger scale in the game world there will be non-scripted changes of power, factions rise and fall, groups come together and disband, though this will take months or even years to happen.  The PC will get to interact and change some events and may even alter the larger course of the game world.  Once the main story is done, however, the emergent stories within the world will continue if the player so chooses to do so.  A second play-through, even with the exact, same starting character will yield different results once the few easy to get to paths are started: the activities of NPCs ensure this.  Thus people who had been met mid-game in a prior instance of the game will have slightly altered viewpoints, may be doing something else in their life, or may not even be available to the PC as they dropped out of FOAF networks the PC uses, or even got a different job somewhere else.  Groups will tend to shift only a little, though individuals in it may be highly variable in any given run of the game.  This will require a player to re-examine their methodology, shift immediate goals and tactics, and then begin exploring other parts of the game world to move forward.  A good deal of Role Playing will come to the forefront as players utilize their PCs abilities, stats, skills and equipment to move forward on an alternate course as the prior instance of the game world is not this new instance and the world does change each time.

Those are my thoughts on what happens when something like the background NPC interaction system of CK2 is merged to become an NPC back-end in an RPG game.  Do note this type of game never presents a truly 'living' world with AI.  Instead it utilizes emergent design to create the game environment, which is something that should be welcomed as a new venue in RPGs.  Older style RPGs will never go away, however, as there are many good and tightly told stories that are extremely compelling that can only be presented in such a manner.  They will always have an audience, if only the gaming industry would understand that.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

At years end, what am I playing?

With my system back up I am now back to a varied play list of games.  In no particular order: - Crusader Kings II - Really, it is the best g...