DevDiary #15 – “The wheels behind the veil” – January 2021

Hello everyone,

It has been a while since we posted our last developer diary. Sorry for that, we were really busy. This time we want to talk a bit about the topic ‘AI’, a topic we only briefly mentioned in our previous diaries. We want to elaborate on what we have done with the AI so far and what we are still planning to do in the upcoming months.

When hearing or talking about AI most people will probably think about our AI dynasties first. And while that is correct, it should be noted that we actually have several AI-controlled systems in the game. NPCs are AI units, but also the entire market restocking system as well as the transporter route calculation and order task generation are done by an AI that we are continuously working on.

But let us focus on our AI dynasties. They have seen a lot of changes in the past months. Most notably we changed the objective system that is controlling their actions and we added some additional systems to take care of all the other things that they should be doing.

One of the biggest and most visible issues is that AI dynasties die. They simply fail to marry or, if they marry, they do not produce offspring. For this we actually found several reasons, all contributing to this, some old and some newly introduced, and some of them very entertaining if you were watching closely.

For example, some characters would go out and romance… everyone. Those little Don Juans and Juanitas would just do romantic interactions with a partner, until they failed. With this their objective failed and they would move on to another objective, like “beg for money”, until they got the objective to find a partner again. Only, instead of resuming their existing romance, they would start a new one. Resulting in them having multiple romantic partners, but none on a level where they could successfully propose marriage.

To fix this, we had to tackle multiple issues. We had to fix the quest structure that handles giving tasks to AI characters, in itself. Now objectives are checked for basic requirements first, so if a character already has a partner, they will not seek a new romance, but resume the existing romance.
Additionally there is a check if a partner is still available for marriage. Romantic partners who are already married, are too old or have a very low score, will be removed as a possible partner, if a character is looking for marriage. This way it is ensured that no fruitless romance is pursued. At least not for too long.
We also added separate quests for pursuing romance/marriage and affairs and make sure that single characters prioritize looking for marriage, rather than pursuing an affair. While this sounds very obvious, it is less obvious on the technical side, as romantic actions are shared between romance and affair.

We also changed the quest structure for our AI to group actions that need to be followed in a certain order. For a human player it might be obvious that a romance needs to be started, then grown through compliments, kisses and sweet talk, until a marriage proposal is likely to be accepted. But our AI needed to learn that not all actions have to be executed in such a manner.
We also allow our AI to turn to other actions, if an action within such a group fails. Prior, our AI would follow all the steps until the very end, even if none of the follow-up steps had a chance of success. So if they failed to start a romance, they had no choice, but to try compliments, sweet talk, even marriage proposals, though they had no partner for it. This is just time and data that is wasted, so it was stopped.

Another issue that we changed is the skills and business buildings that an AI chooses. Originally, the AI chose their skills based on what they could afford and chance. And if a skill or new building was unlocked, again it was mostly chance for it to actually be built.
AI dynasties are now assigned an “Unlock Build” that makes sure skills and professions are unlocked in a way that allows an AI to build businesses that support each other based on their products and unlocked skills. Not one of each because they are the cheapest or the only they can afford.
In addition to that, but still in development, the AI has now a way of managing their budget. So they can save money for unlocks and businesses, equipment, normal expenses etc. This way, they will not spend all their money on the cheapest thing they can afford, but the next thing that makes sense.

What priorities are given and which Unlock Builds are selected depends partially on the Archetype that an AI has. Archetypes refer to a basic attitude (honest/shady, generous/egoistic, diplomatic/aggressive) and they can not be changed. Which means that an aggressive family will always try to choose an action that matches this and is more likely to be assigned an Unlock Build that supports this. They also have access to objectives, particularly created for these types.

As said, the AI is still undergoing a lot of changes and enhancements, so that in the end the AI is both challenging for you and supports the illusion of a living world.

All the best,

Purple Lamp Studios