Created: 2020-01-30 15:47
Last Modified: 2020-01-31 10:36
Building on the foundations of Behavior Based Personality, we now need to determine the motivations for our characters. Why are they engaging in interactions? Is there a master motive, is life just random, how personal are the character's goals? How long can a task take to achieve?
I wrestled with these problems in a damage control simulation for T&E Solutions. And the answer is an interruptible task called a coroutine. Coroutines by themselves don't solve the problem though. They are an implementation of a goal. Goals themselves are intrinsic to the character, though I am toying with the idea of a collective goal for society or groups.
I may slip between terms for things. If I refer to an "agent", I simply mean a character in the story, acting under the direction of our AI framework. I sometimes prefer the term agent to character because not all agents are necessarily human. In our damage control simulation, a room on fire was its own agent. Despite being an inanimate force of nature, it had interactions with the crew and the environment. The most important was to trigger behaviors in the crew to first contain it, and then put it out.
Goals start with a periodic check to see "is everything in order?" If the answer is "no", a coroutine is spawned that will attempt to put the world back in order. If a character decides it is hungry, a coroutine will be spawned that will make the character seek out something to eat. If the character is lonely, a coroutine will be spawned that will make the character seek out conversation. If the character is in danger, a coroutine will spawn to make the character seek safety.
Inside each of these coroutines is a step-by-step branching set of instructions that take some guidance from the personality of the character itself. Let's go with something clear cut: a character is hungry.
Step one is the internal state that equates to hungry is set in the character's mind. Minor hunger is only addressed if the character is no otherwise busy. As the hours press on and the hunger starts altering the character's mood, it becomes a bit more in the forefront of thought. Eventually hunger will become powerful enough to distract the character from what they are doing. And depending on how long hunger has been unaddressed, it may start to cloud the character's judgement. In extreme cases, trigger some really, really nasty behaviors.
Let's just stick with a normal person on a normal diet living a normal day. They wake up, a bit hungry and a bit smelly for their own taste. They address these two matters with breakfast and a shower as part of a morning routine.
At work, breakfast has digested, and the body starts looking forward to lunch. At coffee break they may contemplate what to do for lunch. For some people, part of their morning routine is to pack a lunch. Others head to the cafeteria or the local food vendor stalls. They roll some dice in their head and decide on an eating establishment, or that they are a bit too broke to be eating out (mental note: REMEMBER TO PACK LUNCH TOMORROW). If they are headed out to lunch, and are also in need of some socializing, they may ask a coworker to join them. (Triggering a conversation, with a motivation of "let's get something to eat").
I could simplify things a little but by making the process of going out to eat its own coroutine. But the logic would be the same. There are a series of decisions to make that can spawn other tasks, but following those tasks we resume our higher level task. Decisions made earlier in the process can affect decisions later in the process. How those decisions are made are largely to the taste of the individual character.
This data flow also covers coffee breaks, being distracted by boring subject matter, feeling ill and having to leave after part of the day. Having to run home to attend a sick child. All of those impulses can provide nudges to pop an agent out of their current box, and weight which decisions are required to fulfill outside goals.
In code, these routines turn into step-by-step instructions. Where a decision can be made, it is made. Where more information is needed, or where we are waiting for something, the coroutine has the option to yield. A yield allows the program loop to continue its processing. Think of it like kids nagging "ARE WE THERE YET" and a yield is Mom answering "NO".
Functionally, each agent (or character) maintains a list of the goals and tasks it has spawned to fulfill those goals. If you think of the entire simulation like a board game, each time step the simulation gives each agent a "move". During that move they can perform a unit of work, make decisions, interact with other agents, act on goals, cull completed coroutine, and spawn new coroutines. What exactly the character decides to do is up to the character, though we do limit it to a finite amount of time and limit its interaction to agents it is presently in communications with.
We dole out this time in units. If we are running the simulation in 30 minute steps, each agent can only perform 30 minutes of activity total per step. They spend it like currency as a cost of performing an interaction.
Agents engaged in an interaction will act and react until they run out of time. If we assume that each verbal exchange takes a finite amount of time, we could have cases where one agent's interactions eat up another agent's entire budget for that step. We could also have agents pull a "Well look at the time..." if they have a more pressing desire that requires ending a long-running interaction prematurely.
At the topmost level of an agent is its list of goals and running routines. One routine is given "priority" at a time. Which, and in which order, is up to the agent. Agents can also look at their list of goals and decide to spawn a new routine to fulfill a newly unsatisfied goal.
Now, what are the goals of our agents? One game that had agent-like characters living out their petty existence one desire at a time was Maxis' The Sims. What is nice is that the agents in Sims have a pre-defined set of Motivations:
|Hunger||It is primarily satisfied by consuming food; not fulfilling this need can result in death. Hunger also has a strong effect on job and school performance. A Sim who goes to work or school hungry will not do well.|
|Comfort||It indicates their physical comfort and can be satisfied by having the Sim sit or lie down.|
|Social||Sims crave social interaction, whether it be externally or internally. Which a Sim prefers depends on his or her personality. An introverted Sim will replenish this motive more efficiently chatting metaphysically online with other Sims, texting, or daydreaming about other Sims in their heads. Extroverted Sims will improve the motive in these methods, but would either find the interaction unsatisfying or drop it in favor of calling another Sim on the phone and entering a phone call or inviting the Sim over. Parties are favorable to extroverted Sims, as multiple social partners will fill the need completely in little hours. These often are a fear for introverted Sims who don't have the Popularity aspiration and/or being too young to be comfortable in a crowd.|
|Hygiene||A Sim's hygiene will gradually decrease over the course of the day, and will decrease faster if they are engaged in messy activities. Therefore, it is necessary to take a bath or shower regularly in order to keep the motive up.|
|Fun||Sims, like real people, like to cut loose from the daily grind and enjoy themselves once in a while. Different Sims can have different ideas about what is more fun; for example, a Sim with a playful personality might enjoy watching television or playing computer and arcade games, but a serious Sim would probably rather spend time reading or sitting down to a quiet game of chess.|
|Environment||determines how happy a Sim is with the environment around him or her. It is a combined rating that analyzes the design and content of the room that the Sim is currently standing in.|
|Energy||Energy is a motive in The Sims series that slowly decreases while Sims are awake. If a Sim runs out of energy, he/she will collapse from exhaustion and fall asleep on the floor.|
|Bladder||A basic motive for Sims, pets and other life states in The Sims series. The bladder motive gradually decreases throughout the day, but decreases faster when eating or drinking. Using a toilet or other designated object causes the bladder motive to rise (i.e. relieves the need). If bladder is ignored, it will eventually become urgently low, and an accident can occur if the need is not resolved soon enough.|
That's actually a pretty good start. Just to keep the details fuzzy, I'll eliminate (heh heh) the bladder mechanic. Bathrooms are ubiquitous. There are enough gaps in the action that we can assume bathroom stops happen. Energy would probably be better named "Rest" in this game. Given that I'm not planning on making furniture an in-depth mechanic, I'll probably combine Comfort into Rest. Working all day in an uncomfortable setting will simply wear an agent out faster.
I am anticipating that the game will be played in blocks of time that span several hours (Early, Morning, Noon, Afternoon, Evening, Late). We can assume that regular meals and time to bathe time will be worked into the natural course of a day. If a story element calls for hunger or a messy situation that requires an immediate bath, we can simply script those as part of the event.
Rest could likewise be eliminated, except that the story could involve characters being regularly exhausted. We also want people to behave differently when bright eyed in the morning, vs. tired and sleepy at night.
As far as other biological considerations on behavior, we have enough randomness in our agents decision making to account for them.
With that said I think I'm down to:
|Development||Agents desire to hone their skills, learn, evolve|
|Environment||Agents can comfort or discomfort based on the contents of a room or the other people present|
|Friendship||Agents need to build and maintain social circles|
|Membership||Agents feel the need to contribute to the goals of a group or movement|
|Mystery||Agents have a need to contemplate the unknown|
|Novelty||Agents need stimulation|
|Romance||Agents desire to be in a sexual relationship with a compatible partner|
|Rest||Agents need rest and recreation|
|Security||Agents need to feel safe, and/or like they are in control of their lives|
|Society||Agents have a sense of order in society, and that they have a place within it|
Individual agents have different rules about how events and interactions affect them. Some agents don't need romance, or perhaps find satisfaction of that need in some other way. Some players find mystery in art, others go to church, still others by doing scientific research. Just because we state that all agents have these needs, we aren't proscribing that they are all affected by them the same way, nor do the same activities satisfy the need for all agents in the same way.
For my next trick, I'll be setting up the world's worst Soap Opera.
This page changed. Just now Mon Aug 03 23:13:55 UTC 2020