Starting with the scout AI

Creating the AI discussed in the previous posts is a quite massive project and to make it feasible to code it must be broken down into smaller parts. I decided to start with the scout AI as it’s a ‘relatively’ simple and independent AI module. But even so it’s very important to think through the processes needed, what will happen and how, allowing me to divide the work into smaller pieces. Complex functions often get easier when broken down into smaller components…

Let’s have a look at the scout AI structure again:

This is how I want to scout AI to work:

    Update Landmass – First we update all lists of armies and settlements and check which land mass they are located on. This is done each turn as armies and settlements can be destroyed or change owner.
    Connect Landmasses – At regular intervals (every 10th turn or so) check if scouts have found paths between two landmasses. If it has we must remove the redundant one. This can happen, for example, if a Surface based empire finds two different cave openings into the Netherworld which it enters. This would create two land masses but later the empire might find a path between the two corresponding cave openings in the Netherworld making both land masses represent the same region.
    Identify scout armies - Check which armies that are controlled directly by the scout AI (only armies where all companies has the Scout ability). This list is cleared at the start of each turn to remove eliminated and otherwise changed armies.

Then we loop through all land masses individually:

    Analyze Landmass – Each land mass is analyzed to check if it’s fully scouted. We do this by looking outward from each settlement the AI control on the land mass. The AI personality variable ‘radius’ decides how far out from each settlement the AI wants to keep track of.

    If it’s fully scouted we start moving scouts to disband them. The AI needs to save at least one scout and garrison it in a settlement (garrisoned soldiers require less wages) for use in the future. If it’s not fully scouted we save a list of all sectors that borders unscouted territory in the Landmass object and continue the process.

    Do we have enough scouts – Check if we have enough scouts on the landmass? This depends on how many sectors that borders un-scouted territory (variable that can be modified, again allowing for different behaviors for different AI personalities).

    If no it sends a request for more scouts to the main AI and continue process. Depending on how many scouts that is lacking the request can have different priority settings. If yes we continue the process.

    Issue orders – With help of the list of sectors that borders un-scouted territory, analyze the position of each scout army and issue Tasks for them. Variables control the wanted behavior of the scouts (search in straight line away from known territory or seek in circles around known territory, should two scouts stay close to each other or try to scout as far away from each other as possible).

A couple of things will not be implemented in this first version of the scout AI:

    Patrolling territory that haven’t been seen for a number of turns (controlled by a variable). This is needed for the AI to update the influence map.
    Heavy scouts – Larger scout companies more focused on combat ability which can be used to scout territory that has a larger enemy influence (i.e. enemy controlled regions).
    Influence maps – The influence map must be updated when we scout a sector.
    Construction of watchtowers to increase the territory that is seen by the AI every turn.

In the next post will look at the code for updating and analyzing the different land masses.

Leave a Reply