AI-Uveso (v72). AI mod for FAForever

Moderator: Uveso

Re: AI-Uveso. New mod for FAForever

Postby Uveso » 17 Jul 2018, 20:11

Hello cel00,

all new AI's don't need to be implemented into FAF, they will be loaded as normal mod.
And this is a good thing because the AI can be updated without a game patch.

I don't know if an AI is ever a "good" choice to learn online playing.
But even if we can't match a real player, the new AI's will play different then the old ones.
At least its less boring :)

But like sorian we can add LUA functions to make thinks work like "Sniping ACU" or "Evade Sniping".
I also plan a full AI script only for the ACU, to make it bit smarter.
Lets see how far we can go.

I like the idea that an AI can take over the army of an disconnected player.
And there is already a plan for implement such a system:
(waiting for test/merge)
https://github.com/FAForever/fa/pull/2489
User avatar
Uveso
Supreme Commander
 
Posts: 1538
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 51 times
Been liked: 241 times
FAF User Name: Uveso

Re: AI-Uveso (v39). New AI mod for FAForever

Postby Uveso » 20 Jul 2018, 20:55

Update 20.Jul.2018 (v39)

- Fixed assisting / finisher
- Fixed experimental attack platoon was formed without targets in range
- Added builders for supportfactories
- Added ecomanager for engineers (engineers will now set to pause if eco is too low while assisting)
- Added failsave for stucked factories (lost their forked thread for building)
- Added function to remove mass marker if they are to close to the map border (under 8 mapunits)
- Added option for Buildplatoon priority debugging
- Added option to display all platoon names
- Added translation strings
- Updated assist build plattons
- Updated experimental builders
- Balanced Sub AI Rush (more T2 and T3 units)
- Disabled rallypoint monitor for AI-Uveso. (Setting factory roll off points to main base)
User avatar
Uveso
Supreme Commander
 
Posts: 1538
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 51 times
Been liked: 241 times
FAF User Name: Uveso

Re: AI-Uveso (v39). New AI mod for FAForever

Postby Franck83 » 30 Jul 2018, 17:50

Hi Uveso,

Great your work on AI ! At current work state, does your AI spawn T2 and T3 units ?
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 525
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 105 times
Been liked: 118 times
FAF User Name: Franck83

Re: AI-Uveso (v39). New AI mod for FAForever

Postby Uveso » 30 Jul 2018, 19:41

Hey Franck83,

Thank's a lot :)

Yes, i added platoonbuilder for T2 and T3 mobile units and increased the build chance.
(It also build T2 and T3 buildings)

I updated the last version (v40) to github:
https://github.com/Uveso/AI-Uveso

Don't forget to reaname the github archive folder name when you copy it to the modfolder:

from
Code: Select all
AI-Uveso-master
to
Code: Select all
AI-Uveso
User avatar
Uveso
Supreme Commander
 
Posts: 1538
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 51 times
Been liked: 241 times
FAF User Name: Uveso

Re: AI-Uveso (v41). New AI mod for FAForever

Postby Uveso » 06 Aug 2018, 15:04

Update 06.Aug.2018 (v41)

- AI ecomanager now detects paragon like buildings
- If a paragon is present the AI will no longer build mass or energy
- Increased Assister for building more experimentals
- Added new factory upgrade platoon to upgrade captured factories
- Nuke buildings will no longer build near another nuke building
- Land experimental platoons are no longer using a formation while moving

Also patches from the unreleased "AI Patch V2" are included.
-Fix: reworked sorian unitreplacement (customunits) for factories. Now using all available units.
-Fix: Better error message in case a ACU enhancment fails
-Fix: Added check for missing locationmanager
-Fix: Added check for assisting and building engineers to prevent new orders while still working
-Fix: Unitreplacement is no longer using non existing global squads if an modded unit exist.
-New: Added builder conditon `OverideUpgradeBlueprint` so we can upgrade to supportfactories
-New: Added check for new builder condition `AssistUntilFinished` for engineers
-New: Added `AssistClosestUnit`. Unit will asssit the nearest building, not the one with least assisters
User avatar
Uveso
Supreme Commander
 
Posts: 1538
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 51 times
Been liked: 241 times
FAF User Name: Uveso

Re: AI-Uveso (v41). New AI mod for FAForever

Postby Franck83 » 06 Aug 2018, 15:43

Hi Uveso, nice AI updates. Keep on this good work.

I don't know if it can be modded in AI, but it seems that human players are upgrading their ACU much earlier than AI (gun speed and range, tech 2, shields). It would be nice if AI would add more priority on enhancements. Near 99% of the time, in vs AI games, AI acus are sniped by players.

I would to know too if the threat level of a unit can be modified on the fly.
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 525
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 105 times
Been liked: 118 times
FAF User Name: Franck83

Re: AI-Uveso (v41). New AI mod for FAForever

Postby Uveso » 07 Aug 2018, 01:27

Hey Frank83,

you can't change the threat value of an unit after the blueprint is loaded into the c-engine.
(My AI is not using unit-threats, it simply counts enemy units.)

And yes, the AI can have full control over the ACU with early enhancements and special combat functions or evade functions.
(At the moment my AI uses the ACU as engineer without any additional functions.)

I plan to implement a full ACU-AI later.
Enhancements etc can be managed with build or upgradeplatoons. (copy+paste job)
But i need to program the attack and defence functions for the ACU from scratch.
This can take a while.

Maybe you want to programm some ACU functions ? :mrgreen:
User avatar
Uveso
Supreme Commander
 
Posts: 1538
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 51 times
Been liked: 241 times
FAF User Name: Uveso

Re: AI-Uveso (v41). New AI mod for FAForever

Postby Franck83 » 07 Aug 2018, 07:45

Ty for your answers.

Yes, i would like to take a look at AI ACU. I have no experience on AI. Any tips to start ?
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 525
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 105 times
Been liked: 118 times
FAF User Name: Franck83

Re: AI-Uveso (v41). New AI mod for FAForever

Postby Uveso » 07 Aug 2018, 11:10

There is only 1 place to start :)

The commander has it's own permanent command thread running.
This thread is initialized in the first platoon builder:

Code: Select all
    BuilderGroupName = 'Initial ACU Builders Uveso',                               -- BuilderGroupName, "\lua\AI\AIBaseTemplates\"
    BuildersType = 'EngineerBuilder',
    Builder {
        BuilderName = 'UC CDR Initial Default',
        PlatoonAddBehaviors = { 'CommanderBehaviorUveso', },
        PlatoonTemplate = 'CommanderBuilder',
        Priority = 19500,
        BuilderConditions = {
            { IBC, 'NotPreBuilt', {}},
        },
        InstantCheck = true,
        BuilderType = 'Any',
        PlatoonAddFunctions = { {SAI, 'BuildOnce'}, },
        BuilderData = {
            Construction = {
                AdjacencyCategory = 'MASSEXTRACTION, FACTORY CONSTRUCTION',
                AdjacencyDistance = 50,
                BuildStructures = {
                    'T1LANDFactory',
                    'T1EnergyProduction',
                    'T1EnergyProduction',
                    'T1EnergyProduction',
                }
            }
        }
    },

Here we can see that this builder has an additional "Behavior" function:
Code: Select all
PlatoonAddBehaviors = { 'CommanderBehaviorUveso', },


This means that we not only start building energy and (start)factory, we also add a programm thread to the ACU called "CommanderBehaviorUveso".
It's the same mechanic that we use for air planes (watching for refuel etc.)

This leads us to the file "AIBeahviors.lua" where the function "CommanderBehaviorUveso" is located:
Code: Select all
[...]\Mods\AI-Uveso\hook\lua\AI\AIBehaviors.lua

Here you can find and edit the CommanderBehaviorThread.

There are already 2 main functions present:

Code: Select all
        -- Go back to base
        if not cdr.Dead then
            CDRReturnHomeUveso(aiBrain, cdr)
        end
The upper part is calling the function CDRReturnHomeUveso() and is used to return the commander to the base if he is more then 50 map units away from base.

Code: Select all
        -- Call platoon resume building deal...
        if not cdr.Dead and cdr:IsIdleState() then
            if not cdr.EngineerBuildQueue or table.getn(cdr.EngineerBuildQueue) == 0 then
                --LOG('* CommanderThreadUveso: Idle and no BuildQueue')
                local pool = aiBrain:GetPlatoonUniquelyNamed('ArmyPool')
                aiBrain:AssignUnitsToPlatoon( pool, {cdr}, 'Unassigned', 'None' )
            elseif cdr.EngineerBuildQueue and table.getn(cdr.EngineerBuildQueue) != 0 then
                --LOG('* CommanderThreadUveso: Idle and BuildQueue')
                if not cdr.NotBuildingThread then
                    cdr.NotBuildingThread = cdr:ForkThread(platoon.WatchForNotBuilding)
                end             
            end
        end       
This part is the build function in case a Builder is assingning a buildplatoon to the commander. (don't change it or the ACU will not build anything)


Now you can add functions like the "Go back to base" behavior.

For more examples see the sorian AI thread:
https://github.com/FAForever/fa/blob/develop/lua/AI/AIBehaviors.lua#L1978

[Edit] You can't start ACU-upgrades or enhancments form this thread. They will be initalized with platoonbuilders like here:
https://github.com/FAForever/fa/blob/develop/lua/AI/AIBuilders/AIEconomicBuilders.lua#L741
User avatar
Uveso
Supreme Commander
 
Posts: 1538
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 51 times
Been liked: 241 times
FAF User Name: Uveso

Re: AI-Uveso (v41). New AI mod for FAForever

Postby Franck83 » 08 Aug 2018, 14:27

Ty a lot,

if i understand well, Builders are triggers of constructions and platoon attacks depending of conditions ? And you can add function with units orders sequences on a builder.

Then how builder actions are managed ? higher priority triggered all the time if conditions are ok ?
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 525
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 105 times
Been liked: 118 times
FAF User Name: Franck83

PreviousNext

Return to AI modifications

Who is online

Users browsing this forum: No registered users and 1 guest