Skip to content

[Feature]: Refactor UnitCapWatchThread for default AI #6722

@relent0r

Description

@relent0r

Describe the Feature

The UniCapWatchThread is a piece of logic that runs every 30 seconds. It checks the unit cap and kills units if it is close to its cap.

The AI also has some builder conditions that will return false if the AI is within a certain ration of its cap.

The issue : The current logic uses this to determine when to action its logic.

if GetArmyUnitCostTotal(aiBrain:GetArmyIndex()) > (GetArmyUnitCap(aiBrain:GetArmyIndex()) - 10) then

This is not inline with its builder condition ratios so the AI will stop producing units long before this triggers.

The more important part is how it handles culling units.
It will get a list of T1 mobile land units and kill up to 20 of them.
It will get a list of T1 direct fire defense units and kill up to 20 of them.

I'll be refactoring this to make it take into account other unit types and perform more validation of the units that it culls so that on 20km+ maps the AI does not constantly run into unit count issues.

Expected Behavior

AI can cull lower tier units when it hits unit counts that will be inline with what it currently has and covers more unit types such as Air, Naval etc.

Screenshots

No response

Additional context

I'm going through the process on rewriting how this functions for my own AI so will port back improvements that I believe will help the default AI.

Metadata

Metadata

Assignees

Labels

area: AIrelated to AI functions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions