Now I am working on the initial AI engine for the game. You’d think that with my Ph.D. in experimental psychology I’d know better, but it wasn’t until I started brainstorming how I wanted the AI to work did it really strike me how complex behavior can be. Even for the simplistic abstraction that I intend to code for Fief, there is a lot of complex behavioral patterns that I wish to see realized to really provide the right “feel”.
So like any good programmer, I started “modulizing” things into small manageable chunks. This post outlines my current plan for behavior that I am working on. Thankfully, one chunk of this is already coded and working great, the Action.
The Action is a small (typically 1-step) chunk of the current action for a creature. My next step was to step back and ask myself, “where do our actions come from?” Typically some decision stage decides our current action. I think there are two answers here for how those actions are decided on, our goals and our emotions. So I added a decision stage that plans the next Action based on emotions and goals. Of course, then I must ask “what determines one’s goals?” and “what determines one’s emotions?”
For goals, I’ll get to emotions below, I decided that our current societal role typically determines one’s goals. If I’m a farmer, my goal is to plant my seeds. If I’m a blacksmith, my goal is to repair the items given to me, and possibly forge some new ones based on requests. And so forth…
This creates the three level approach I am using to codify the behavior in Fief, illustrated by the following figure:
- Role is long-term behavior.
- Goals are short-term behavior.
- Actions are immediate behavior.
Roles come in two flavors. Job roles and Rank roles. When a peasant is assigned to a particular job site, they are given a job role at that site. This is their job role which will determine which goals are generated and therefore which actions are generated. For example: Bobbert is assigned to the Lumber Camp in the role of Lumberjack. The job Goal given to him will likely be to Gather Resources for the associated job site. In this case, trees. The Actions that will be generated for him, based on this goal, including chopping down trees, cutting those trees into blocks and boards, and bringing those items to the lumber camp.
Now for Rank roles, Bobbert is a peasant. He is assigned a job from his lord (i.e. you, the player). However, he will be given a plot to live on. He might have a family there as well. During the work hours the Job role will assign the Goals that govern his behavior, but in the off hours, his family and social status will determine the Goals generated. The spouse of a worker (male or female) takes care of the garden, cooks, cleans, and looks after young children during these work hours. But in the off hours the family should spend time together, doing chores and looking after their own interests.
Another factor, coming back to the emotions here, is the person’s personality. I wanted to create a model of personality that is both fun, simple, but has a touch of realism. I immediately thought of the Big Five personality traits, but thought this was a bit too much for my purposes. I then came across a model that really fits the style of the game. I’ll talk more about this in the next post… back to coding!