Skip to content

New AI Teams Selector - #810

Open
FS-21 wants to merge 92 commits into
Phobos-developers:developfrom
FS-21:feature/new-ai-team-selector
Open

New AI Teams Selector#810
FS-21 wants to merge 92 commits into
Phobos-developers:developfrom
FS-21:feature/new-ai-team-selector

Conversation

@FS-21

@FS-21 FS-21 commented Dec 3, 2022

Copy link
Copy Markdown
Contributor

More details in the documentation:

  • New AI system for selecting valid triggers in multiplayer randomly. Unlike the original method this one checks prerequisites and take care of other details.
  • It can split the valid triggers into 5 categories: ground vehicles, infantry, air, naval & mixed categories. If set, AI picks a random trigger in a random category.
  • Categories can have different chance probabilities. It can be set globally or customized per house. By default each category has a 20% chance to be selected.
  • NewTeamsSelector.MergeUnclassifiedCategoryWith can be used for merging the mixed category (units are from different categories) into one of the main categories.
  • In case of picking a category without valid triggers exist a fallback mode that allow picking a trigger from all valid triggers like if categories were disabled.
  • If Autocreate=yes AI will care about all units prerequisites so if the house's tech tree is incomplete for the trigger it gets discarded. It understands Ares tags like Prerequisite.RequiredTheaters, Prerequisite.Negative, Prerequisite.Lists & Generic prerequisites section.
  • NewTeamsSelector.VIPWeight controls the VIP trigger threshold. If a trigger meets this threshold, AI discards non-VIP candidates and picks exclusively from VIP triggers with equal chance (categories are bypassed in VIP mode).
    • Defaults to 5000.0 (vanilla behavior).
    • Setting NewTeamsSelector.VIPWeight=-1 enables dynamic VIP mode where each trigger becomes VIP when its Weight_Current >= Weight_Maximum.
    • Setting NewTeamsSelector.VIPWeight=0 disables VIP mode completely.
  • Units can override the category using ConsideredVehicle and ConsideredNaval boolean tags.
  • AI is able to use unlocked units in captured Secret Labs.

In rulesmd.ini:

[AI]
NewTeamsSelector=false                               ; boolean
NewTeamsSelector.SplitTriggersByCategory=true        ; boolean
NewTeamsSelector.EnableFallback=false                ; boolean
NewTeamsSelector.GroundCategoryPercentage=0.20       ; floating point value, percents or absolute
NewTeamsSelector.InfantryCategoryPercentage=0.20     ; floating point value, percents or absolute
NewTeamsSelector.NavalCategoryPercentage=0.20        ; floating point value, percents or absolute
NewTeamsSelector.AirCategoryPercentage=0.20          ; floating point value, percents or absolute
NewTeamsSelector.UnclassifiedCategoryPercentage=0.20 ; floating point value, percents or absolute
NewTeamsSelector.MergeUnclassifiedCategoryWith=-1    ; Integer - Ground: 1, Air: 2, Naval: 3, Infantry: 4
NewTeamsSelector.VIPWeight=5000.0                    ; floating point value, -1 for dynamic max weight, 0 to disable

[SOMEHOUSE]                                       ; HouseType
NewTeamsSelector.MergeUnclassifiedCategoryWith=   ; Integer - Ground: 1, Air: 2, Naval: 3, Infantry: 4
NewTeamsSelector.UnclassifiedCategoryPercentage=  ; floating point value, percents or absolute
NewTeamsSelector.GroundCategoryPercentage=        ; floating point value, percents or absolute
NewTeamsSelector.InfantryCategoryPercentage=      ; floating point value, percents or absolute
NewTeamsSelector.AirCategoryPercentage=           ; floating point value, percents or absolute
NewTeamsSelector.NavalCategoryPercentage=         ; floating point value, percents or absolute
NewTeamsSelector.VIPWeight=                       ; floating point value, -1 for dynamic max weight, 0 to disable

[SOMETECHNO]        ; TechnoType
ConsideredNaval=    ; boolean
ConsideredVehicle=  ; boolean
  • Modified slightly AI Trigger conditions 0 (enemy owns ...), 1 (house owns ...) and 7 (civilian owns ...) and added 10 new conditions (from 8 to 17) that check lists of objects instead of only 1 unit. The first 3 were modified because the objects counters weren't updated in real-time. The possible modified and new cases are:
Condition List of objects Description
0 (changed) No Count objects of the main enemy. If AI house doesn't have a main enemy It will search in all enemies. In vanilla YR if house doesn't have a main enemy this condition fail
1 (changed) No Count own objects
7 (changed) No Count civilian objects
8 No Count enemy objects. It will search in all enemies
9 Yes Count enemy objects. If AI house doesn't have a main enemy It will search in all enemies.
10 Yes Count own objects
11 Yes Count civilian objects
12 Yes Count enemy objects. It will search in all enemies
13 Yes Count objects from allies
14 Yes Count enemy objects. If AI house doesn't have a main enemy It will search in all enemies. It uses AND comparator so each object must obey the same comparations
15 Yes Count own objects. It uses AND comparator so each object must obey the same comparations
16 Yes Count civilian objects. It uses AND comparator so each object must obey the same comparations
17 Yes Count enemy objects. It will search in all enemies. It uses AND comparator so each object must obey the same comparations
18 No Count structures with BridgeRepairHut=yes linked with destroyed bridges
19 No Count structures with BridgeRepairHut=yes linked with undamaged bridges
  • Some trigger conditions need to specify a 0-based list from [AITargetTypes]. The index of the list is written in hexadecimal and in little endian format. The value must be written at the end of the trigger:
    00000000000000000000000000000000000000000000000000000000AABBCCDD
    For example: list 0 is written 00 (put it in AA), list 1 is written 01 (put it in AA), list 10 is written 0A (put it in AA), 255 is 0xFF (put it in AA) and 256 is 0x0001 (put it in AABB), etc.
  • The AITargetTypes index# values are obtained in the new AITargetTypes section that must be declared in rulesmd.ini:

In rulesmd.ini:

[AITargetTypes]  ; List of TechnoType lists
0=SOMETECHNOTYPE,SOMEOTHERTECHNOTYPE,SAMPLETECHNOTYPE
1=ANOTHERTECHNOTYPE,YETANOTHERTECHNOTYPE
; ...

@github-actions

github-actions Bot commented Dec 3, 2022

Copy link
Copy Markdown

Nightly build for this pull request:

FS-21 added 2 commits January 11, 2023 07:11
Fixed all the bugs related to the Teams categorization, now all the AI teams go to the right category depending the members of the Taskforce.

Added 2 new boolean tags for overwriting the categorization of some units:
- ConsideredNaval
- ConsideredVehicle
@Starkku
Starkku force-pushed the develop branch 2 times, most recently from aae92fd to a32076e Compare June 3, 2023 10:14
@github-actions

github-actions Bot commented Jul 22, 2023

Copy link
Copy Markdown

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

FS-21 added 29 commits September 2, 2025 11:12
- Prerequisite tags were cleaned after a change of map/restart.
- More laxed when adding the AI triggers in their respective houses arrays. The main Team's selection loop will decide if the trigger is currently valid.
- Some code tweaks & additional log lines in the AI selection loop.
- Now AI teams are directly discarded from the selection loop if doesn't exist the required factories if Autocreate=yes
… proportional category rolling, and integer side comparison
…targets are reachable from factories"

This reverts commit 48320ef.
@FS-21

FS-21 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Reworked & optimized, updated docs and first post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Major Big stuff to do Needs improvement ⚙️T2 T2 maintainer review is sufficient

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants