Tuesday, September 25, 2012

Sketching ideas for a rpg social system

Firstly, it has to be an agent based model.  No other options.

Use a small-worlds network based on proximity but with travel and some mixing functions over time. This network can provide the information propogation system, friends and enemys mechanism, trading model, etc.

The other option is to use different network models for different "classes" of agents. Perhaps a mix, to represent different concepts.  Small world network for the information propogation, while a context free network for trade?  Have to have a play...  maybe invent some other topologies.

The various agents decision making models will be dynamic with LOD for the proximity to players.  So when the player is distant from the agent in both proximity and network, the agent will degrade to a very simple state machine.  (Essentially going through the motions and just doing the "big stuff") until the player gets closer at which time the complexity of the decision making model can be increased to improve the fidellity of the players local experience.  When the player is interacting with the agent, the agent will move up to some sort of voting based multi layer Utility model.  This should provide the highest fidelity interactions. 

(It would be funny if there was a feedback system where the agents could identify their own LOD as part of their utility model and see if an emergent behaviour of trying to stay near the player emerged. See if we could get all the agents in the game to "flock" around the player.)

In an effort to simplify the environment for the mobil agents, I think its best to represent the environment as a set of abstractions ( or simpler, less mobile agents) Specifically, represent the social environment such as towns as an agent.  This layer of agents can then act to recruit new residents, manage all the functions of the town using some heuristic model and generally model all the bits that we don't want to spend the effort to get working with emergent behaviour.  Things like trade, markets, festivals, law and order, development, reconstrcution etc.

As processor power becomes availible (player inactivity) additional resources can be passed out to improve various locations based on player activity. We could also use it for "sweeps" to check for agent stupidity and "fix" it before the player finds it. (Agents in walls, buildings built on each other etc)

Social units such as families, gangs, tribes, associations, brotherhoods/sisterhoods etc can all be repesented by an abstract "group" agent.  These again act to model all the functionality of the group such as recruiting, maininting order, creating missions, trade, group knowledge, friend and foe etc. 

Using some sort of delegate model, large social group agents can spawn and delegate-to smaller social group agents as temporary holders.  For instance, when a large social group needs to divide ( imagine a scenario where a tribe of goblins seperates, one sub-group pursues the player, while the second sub-group returns to the goblins cave to keep the home fires burning) the agent which was driving the group can sub-divide and create a sub-agent with orders to pursue the player (within some conditions) and then return to the main group.  This allows the main group agent to degrade to a lower LOD if the player moves away from the main group and allows the smaller pursuit group to act in a much more complex way, than if a single fairly simple agent was trying to drive a whole tribe after the player. 

As the group agents divide and delegate roles to their sub-agents, this can create a great deal of complex behaviour with the group agents driving the big stuff and individual agents handing issues like local path finding, combat, ambient behaviour etc. It should also allow for some interesting (and cheap) distributed behaviour amoung groups. 
Internal group communication can be modeled almost instantatious, which could be used for all sorts of things.  It can be used for effective flocking behaviour, but also for mob attacks, distributed "watch" systems and coordinated attacks and defense.

Some control will need to be placed on the rate of spawn of these sub groups to make sure there is no "chatter" effect of agents on boundaries which cause sub-groups to be defined then re-attached, then defined and re-attached...etc.  Forcing the sub-group to exist for a minimum lifetime would be a simple mechanism, even if they are within some proximity to re-attach. 

How do we deal with orphan groups?  Imagine a scenario where a goblin tribe is split into two, one being the origional "tribe" agent, while the other is a delegated "hunting party" group.  While the hunting party is out, the main tribe group is wiped out in a horrible kitche fire accident and the group agent enters some sort of termination state.  I guess if it retains a link to all sub-agents and they still have members who are alive then it has no reason to terminate.  Ok... not really an orphan as long as they are linked.

What about preventing massive fragmentation of groups?  Minimum member rules? (Group cannot be spawned with less than X members)  Recruit rules? (When they are out of sight of the player they can re-spawn at a given rate to replenish their numbes?)

 There is only so much trouble the player can get into at any one time, so perhaps this would not happen.  As once the player moves out of range, the sub-groups would collapse back into the main group and the fragmentation disapears.

There is still the chance of fragmentation when two groups collide.  In the event that the player creates some sort of massed fighting group and goes and has a large scale battle with another group... then it should be possible for both groups to break apart into smaller units and potentially generate a large number of sub-group agents.  At some point, in a battle, most of these sub-groups are going to be decimated and the remaining members will need some mechanism to collapse back to the grandparent agent.  In the event the individual agents all maintain a link back to the grandparent agent and if they are isolated, simply make their way back as best they can ( or control returns to the grandparent agent, which allocates them to another existing sub-group that maybe nearby.  kinda cheating, but should work convincingly)

The interesting possibility of dynamic and learning agents at these various levels will create some level of dynamic change in the game.  It would be interesting to allow the town agent to respond to the level of damage of buildings by changing the type of buildings or re-modelling existing builds to be more robust.  The converse is true.. for a town that is rich and prosperous without any damage.... make it more decorative and less secure.
Giving significant agents some sort of memory/learning variables that can evolve them in different ways to the players and other groups activities as well as the games general level mechanic will allow the game to display some emergent behaviour.  Where there is simple inter-group predation without the interaction of the player, it should generate an environment that represents that reality.  Buildings should be fortified, people should be wary and there should be some dynamic friction between the groups.  By combining a mix of cyclical factors , ossciliators and boundary seeking algorithums, it will be possible to generate a range of fragile, stable or unstble scenarios for the player to disturbe.  More interesting situations could be created where the player acts as the damper or a supressor.  (Local lawman type scenario) where every time the player leaves the area, the problems flare up again.  The player will then need to learn the dynamics of the sitaution and figure out ways to solve them.

This kind of model will generate a whole mass of emergent behaviour, highly complex group dynamics, inter-group dynamics, all the way down to individual dynamic behaviour.

Now to add some really emergent fun, provide a general library of strategies and behaviours and allow all agents to pick from them.  Then allow a collective learning algorithm to "learn" the player and weight the shared behaviour library in terms of value around the players style.  This will allow the game to adapt to the players style and skill and hopefully raise the challenge level for the player over time.  The other major use of this library should be to enrich the behaviour of any companions that the player hangs out with.  They should learn to play along side the player and gain experience, better strateies and become more helpful as they see the player adapt.  There could be an order system or the player just does their thing and the companion learns how to support that behaviour.  (Cautious, attacking, stand and fire ranged weapons, circle and attack, move to high ground, put their back to something, run and hide... etc)

No comments:

Post a Comment