1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development Diary #13: A day (turn) in the life of a character in AotSS

Discussion in 'Development Diaries - Written' started by dirkgently, Aug 8, 2016.

  1. dirkgently

    dirkgently Lord of Statistics
    Staff Member Developer Forum Admin Testing The Galaxy, One Star At A Time

    Country:
    United Kingdom
    Joined:
    May 5, 2015
    Messages:
    158
    Likes Received:
    36
    Hi all, Oliver here! Today I’m going to be talking in a little more detail about how our AI system will work.

    Because Alliance of the Sacred Suns is a turn-based game, the AI isn’t constantly calculating what to do. Instead, each character, including the player, takes a turn, and over the course of that turn, the (other) AIs mostly just react to the active AI’s actions. (We may do some clever things with AI decision-making in the background of other characters’ turns, in order to shorten the turn calculation time, but the basic principle is IGOUGO.) The active character, in contrast, will be running quite a sophisticated algorithm to decide what exactly they’re going to do with their time.

    First of all, they have to take stock of their situation. At the start of each character’s turn, they check their Attention Bidding System. This is a function that chooses between different possible goals for the character to work towards, based on weights assigned to those goals. For some goals, such as getting rich, these weights are pretty constant, only varying with the character’s fundamental personality and Ultimate Goal (their overall desire in life). For others, the weight will depend on their circumstances – ‘Survival’, for example, takes a weight determined by the highest Threat Level of any character to the active character. (Threat Level is a figure set by a combination of a character’s Power with modifiers for other factors, such as threats they’ve made and Secrets the active character knows about them.) The goal they’re currently working towards also has a bonus to its weight, to make sure characters stay plausibly focussed.

    Once the Attention Bidding System’s check has been made, the character then starts moving on the Strategy Tree. This is a branching tree of hand-written decision nodes, designed to try and emulate real human reasoning by proceeding from ultimate motives, through general strategies, to specific actions. But rather than starting from the top of the tree each time, unless they’ve changed their end goal, the character will pick up wherever they left off at the end of their last turn. (Again, this is to make sure they maintain coherent courses of action over time.) The character will then proceed through the tree according to the rules on each node they come to, until they come to a node telling them to perform an action of some kind. When they come to a node of this sort, they will spend an Action Point, perform the action, and then check their Attention Bidding System again, to make sure circumstances haven’t changed what they ought to be doing – for example, if they’ve Challenged a character more powerful than they are, they may suddenly need to move to the Survival branch of the tree! Then, if they have Action Points left, they will start moving through the tree again, repeating the process until they run out of APs.

    So that’s the overview of the system. Let’s have a look at an example, to see how this’ll work in practice.

    Mancy Ononoke is the young viceroy of the planet Lucidia. Her Ultimate Goal in life is Wealth, which means that’s one of the goals she has under consideration, and since she’s a very Driven young woman, its weighting is quite high, outbidding the moderate threat from the popular Gaius Locke, also resident on Lucidia, for her attention. Now since she was busy on a pilgrimage until last turn, she starts from the top of the Wealth branch of the strategy tree. First, she decides what broad strategy she will pursue to make her money: since she’s a Viceroy, she makes the easy choice to Develop her Territory (a node directly under ‘Ultimate Goal: Wealth’). Now, how to do that? ‘Develop Territory’ has three child nodes, but two of them are available only to senior clergy and province governors, respectively. So she opts for the third, ‘Improve Economic Sector’.

    ‘Improve Economic Sector’ is a node that can be accessed from a number of different places, so it has options for which planet and sector of the economy to improve. Choosing which planet to improve is easy when there’s only one option, but selecting which sector to improve is more complex. Mancy considers unemployment, production capacity, and the skill of her workers in order to pick the Energy sector. She then, following the node’s script, determines that the best way to improve that sector is by building more power plants. Therefore, she moves down to Adjust Build Plan, and spends an Action Point to alter her planet’s build plan to favour building them. The instructions then tell her to wait to see how effective it is, so she discards the rest of her Action Points, and the turn ends.

    Mancy doesn’t have to just sit around waiting, of course. Many goals can be pursued as ‘break activities’, meaning they can interrupt other activities without disrupting them completely – once the break activity is finished, the character goes right back to what they were doing. ‘Survival’ – in this case, tackling the threat of Mr. Locke – is such an activity, and, since she’s waiting, she gives break activities a higher weighting in the bidding for her attention. So, next turn, she might decide to deal with Locke once and for all! But she might also choose to start building a family, spend time with her friends, do something for the Church, or any one of a number of different things. There are over 500 nodes on the strategy tree, with twelve different goals bidding for characters’ attention, and many different ways to achieve those goals, creating a dynamic, storytelling system in which characters act plausibly in pursuit of believable motivations.

    Not only that, but since the system is completely modular, modders will be able to add new nodes and modify existing ones. Different branches can cross-reference one another (with a customisable limit on absolute tree depth, to prevent infinite loops) meaning that some nodes added to one branch can be used intelligently by characters pursuing other goals. (Assuming, that is, the nodes are well-written!)

    Now some of you will be reading this and thinking, ‘That’s all well and good, but how many hours am I going to have to sit and wait for each turn to resolve?’ We’re very aware of the potential performance issues involved in such a procedure, so we also plan to iteratively develop an ‘AI director’ system to switch characters between this process and a much simpler, more efficient one, in order to provide the player with a better experience. This other system will be much lower-fidelity and have many fewer options, making the decision process much faster, but crucially, you won’t know which character is running what at any given time – a character who doesn’t seem to be doing much proactively might not be, but on the other hand, they might be busy plotting behind your back…

    It’s a very exciting time for me personally right now, because having worked on the detailed design of this system for almost a year, we’re on the point of beginning to implement it! Keep your eye on the blog – we’re going to have a lot to show off in the coming weeks and months.

    Ave Imperator!

    Oliver
     
    #1

Share This Page