Well… it happened again. I completely reworked the behavior system. But I think I am done with it this time around. I guess it’s not completely different, just some major tweaking.
I’ve been reading a lot of journal articles in the robotics literature to see what kind of programming hierarchies they use to control behavior. While I didn’t find any models that directly worked in my application, I did get a lot of good ideas and helped to reformulate the problem.
Here’s an illustration of the new Three Roles model:
Rather than having some overarching “decider” working out behavior for each entity, I wanted to proper simulate each entity working autonomously and making its own decisions with what information it has. The three roles outlined above help facilitate this functionality.
The Social role represents the person’s role in society and social status. This role largely determines how a creature/person fulfills their needs and responds to dangerous events. Think of this role as the ‘id’. Non-people creature’s only have this role.
The Family role represents the person’s role in their family and household structure. This role largely deals with how the person will respond the the needs of family members.
The Job role represents the person’s role at the workplace or the manor at large. This role is will largely offer new behaviors based on job tasks assigned to the person.
On every update cycle, each role is given the opportunity to set behavior (by setting the current Goal). However, they can only offer a new behavior, which will only manifest if the new behavior has a higher priority than the current one. Furthermore, their is an order of precedence, such that the Social role offers first (since these are usually the most pertinent events), then the Family role, then the Job role. Additionally, a person’s personality will determine the weighting (priorities) assigned to each behavior, such that more selfless personalities are more likely to help others before seeing to their own needs.
Additionally, behavior can be modified through interrupt events. For example, when a person is injured they will broadcast an interrupt event around them to all creatures. Most creatures will ignore the event, but if another person nearby is a family member, that may trigger an interrupt event in that person to assist the broadcasting person. Another example is the interrupt event of hunger, where a person interrupts their own behavior because their hunger level is low. Interrupt events will also be broadcast to the player, but usually only result in a message being displayed in the console.
My goal with these changes is to create some life-like behaviors in the denizens of the manor. Now that I have this framework together, I have been frantically coding all the different Goal’s that represent a modular chunk of behavior.