top of page
  • Join our Discord!
  • Join our Kickstarter!

A.I. part TWO

Updated: Nov 29, 2022

Welcome to the second part of the AI devlog.


As described in the last devlog example, the AI follows the strategy of producing 10 times more energy than resources. Of course, we also need a strategy for this, which ensures that more resources are produced.



As a strategy condition we use "MoreThanGameTimeSeconds"(1) here. This means that this strategy is active from the first second of the game for the rest of the game.


Here we have 2 strategies for energy and resources that can be active at the same time.

The resource strategy is always active, and the energy strategy activates when less than 10 times the amount of energy is produced compared to resources.


Finally the strategy manager produces a table with the strategy names that need to be executed.







The base, extensions and other locations.



Now that we have one or more strategies, they need to be executed somewhere.

To do this, we will define locations on the map where we will execute the strategies.


The first location is the main base and is created at the commander's or factory/engineer's location. The "AILocationCreator" is responsible for this. If necessary, this also creates new locations as extensions or outposts. For example, if the AI is gifted units or buildings and there is no base nearby, a new one will simply be created.


After a new base or extension is created, 2 more Lua functions start for that location.

First the "AILocationManager" starts. It reads the list of strategies and checks which builds or unit formers need to be activated for that location.

Build or unit former typically looks like this:























Debug: When set to true, this allows the individual former to be examined without the full locationmanager log.

FormerName: A random name for this former

RunWithStrategy: Here are the names of the strategies with which this former should be executed

Priority: Determines the importance of this former

RunOnBaseType: Specifies on which base type this former is applied.

AIPlan: The name of the Lua function that this former should execute.


NeedMobileBuilder: Here it is specified which and how many technicians we need.

First the exact description of the unit is set. (MOBILE + ENGINEER + TECH1)

Followed by 2 numbers, the minimum and maximum number of technicians we want to use.

The second unit specification is in case the conditions for the first unit were not met.

In our case here we use the commander when no technicians are available.


FormerConditions: As with the strategy, it is decided here whether and when the former is used.

wantStructures: As with the technicians, here we only indicate the categories of the unit.

desiresAssist: If more technicians are needed to assist, this can be specified here.



Ok, but now we build it ?




The second Lua function "AILocationExecutor" is responsible for executing the shapers specified by "AILocationManager". In our case, these are the formers for the "BuildMoreResource" and "BuildMoreEnergy" strategies. Here the orders are passed on to individual specialized program functions, which look for the required units and execute their commands, such as build or attack.



And it's being built!



Thanks for the attention, see you in the next AI devlog.


Regads, Uveso.

576 views0 comments

Recent Posts

See All

Comments


bottom of page