AI-Uveso (v51). AI mod for FAForever

Moderator: Uveso

Re: AI-Uveso (v49). AI mod for FAForever

Postby Uveso » 03 Jan 2019, 03:41

Well yes, the game is not a blackbox to us and we know the bugs/glitches of the game.

As example we have an command to geta list of enemy units, but we know that we also get allyed units listed with this command.
So we hocked that function and added a filter to get rid of the allied units. And now the function makes what it should.
It's now only returning a list of enemy units.

Another example is the fact that the c-engine can't build on the map border closer then 8 map units.
So i added a function to filter out massextractors that are to close to the map border in LUA.
This way the AI don't get stuck when it gives a buildcommand from LUA but the c-engine is not executing it.

And we made lists with all ingame commands and commented them:

Core commands:
https://github.com/FAForever/fa/blob/develop/engine/Core.lua

Commands you can use Sim-side:
https://github.com/FAForever/fa/blob/develop/engine/Sim.lua

Commands you can use UI-side:
https://github.com/FAForever/fa/blob/develop/engine/User.lua



While programming my AI i also checked every function from the GPG AI before i used it.
And i fixed many bugs while doing this.
In case you want to know what i have changed inside the maingame for AI's:
AI patch 1:
https://github.com/FAForever/fa/pull/2468
AI patch 2:
https://github.com/FAForever/fa/pull/2566
AI patch 3:
https://github.com/FAForever/fa/pull/2660

(That's why the FAF version of sorian and GPG AI are about 10% stronger then their originals.)


I also created almost every platoon function for my AI by myself:
Here you can see the platoon.lua code from my AI:
(line 1-860 are only patches for the game, my code starts at line 861)
https://github.com/Uveso/AI-Uveso/blob/master/hook/lua/platoon.lua#L861


And we created a mini AI in case ppl want to start to programm their own AI:
http://forums.faforever.com/viewtopic.php?f=88&t=16323

I don't know how much information sorian had about the game, but i have everything i need ;)
At least i don't see anything we can't do with the AI.

And there are many coders here with way more experience then i have!

So, back to your question, yes we have a good visibility of the game here on FAF :)
User avatar
Uveso
Supreme Commander
 
Posts: 1274
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 46 times
Been liked: 190 times
FAF User Name: Uveso

Re: AI-Uveso (v50). AI mod for FAForever

Postby Uveso » 03 Jan 2019, 22:58

Update 03.Jan.2019(v50)

- Fix: AI now also works with the Nomads mod. (changed hooknames to prevent destructive hooking)
- Fix: Targetfunction is now ignoring the seraphim energy being
- Fix: Targetfunction will now also ignore targets where capturing is in progress.
User avatar
Uveso
Supreme Commander
 
Posts: 1274
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 46 times
Been liked: 190 times
FAF User Name: Uveso

Re: AI-Uveso (v50). AI mod for FAForever

Postby relent0r » 04 Jan 2019, 00:21

Thanks for the great info Uveso, the MicroAI is very cool to help get started with.
Silly question but I was wondering about the platoon.lua file you've done. Is it a direct replacement for the default one or does it merge it or something? You reference a GuardUnit plan in your platoon templates but that doesn't exist in your platoon file.

Have explored the strategy manager much yet? I remember Sorian was looking to work with it in his ai.
relent0r
 
Posts: 7
Joined: 30 Dec 2018, 23:22
Has liked: 0 time
Been liked: 0 time
FAF User Name: relentless

Re: AI-Uveso (v50). AI mod for FAForever

Postby Uveso » 04 Jan 2019, 00:56

Hello relent0r,

yes indeed the platoon.lua file in my mod is a hook.

Hook means, the file from my mod will be appended to the original file at game start.

The hook inside the platoon.lua file is simple.
Code: Select all
TheOldPlatoon = Platoon
Platoon = Class(TheOldPlatoon) {

    CustomFunctionName = function(self)
        -- Your code stuff
    end,

}

or if you want to change an existing function:
Code: Select all
TheOldPlatoon = Platoon
Platoon = Class(TheOldPlatoon) {

    ManagerEngineerAssistAI= function(self)
        -- First call the original function, so we dont break things
        TheOldPlatoon.ManagerEngineerAssistAI(self)
        -- Your code stuff
    end,

}


First we do a copy from the Platoon class into TheOldPlatoon.
Code: Select all
TheOldPlatoon = Platoon

Then we overwrite the old Platoon class and use as base the original Platoon (saved in TheOldPlatoon)
Code: Select all
Platoon = Class(TheOldPlatoon)

If we need to call a function from the old platoon class, then we can call it from the hook with
Code: Select all
TheOldPlatoon.FunctionName()


Now if i call the function GuardUnit and its not inside my hook file, then it inside the original file:
https://github.com/FAForever/fa/blob/3a ... n.lua#L663

I have looked into the strategy manager, but can't use it for my AI.
Its also not finished and has not more then a lua file with zero functions.
User avatar
Uveso
Supreme Commander
 
Posts: 1274
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 46 times
Been liked: 190 times
FAF User Name: Uveso

Re: AI-Uveso (v50). AI mod for FAForever

Postby relent0r » 09 Jan 2019, 04:48

again thanks for the great info. I've been spending a bunch of time looking at the default ai implementation.

reason I asked about the strat manager was I wondering what potential there is for condition specific tactics, similar to what they did in the campaign where they had custom ai scripts per map for implementing map specific tactics. In the campaign they housed the scenario file and ai files with the map itself so I'm not sure if its possible with the default skirmish maps.
relent0r
 
Posts: 7
Joined: 30 Dec 2018, 23:22
Has liked: 0 time
Been liked: 0 time
FAF User Name: relentless

Re: AI-Uveso (v50). AI mod for FAForever

Postby Uveso » 09 Jan 2019, 06:53

Hello relent0r,

the whole AI code is in LUA, so we have full control over everything.
(If you have the time/skill)

So yes, you can reactivate the strategy manager and let it execute your own functions.

But as I said, i/we don't need it.

As example;
You could use the strategy manager to decide if your AI will build more naval or air units and activate/disable the corresponding buildplatoons.

I am (my AI) is using a simple buildcondition for it.
The buildplatoon for naval units has a buildcondition to check the land/water ratio, if we have more than 50% water on the map then we build more naval units.

There are also buildconditiosn to check if we can move on land to the enemy. If we can't move on land, then we don't build land units but more air and so on.

That's why i never tried to use the strategy manager.
User avatar
Uveso
Supreme Commander
 
Posts: 1274
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 46 times
Been liked: 190 times
FAF User Name: Uveso

Re: AI-Uveso (v50). AI mod for FAForever

Postby relent0r » 11 Jan 2019, 00:23

I was thinking of smaller scripted actions (similar to the SACUTeleportAI function you use) that would need to happen after x gametime, but the bit I wasn't sure about is if you could reference specific maps in these functions. i.e if mapname = 'scmp-bla' and getgatetimeseconds <= xxx , for things like engineer drops I'd need to use absolute map positions rather than the map markers.
relent0r
 
Posts: 7
Joined: 30 Dec 2018, 23:22
Has liked: 0 time
Been liked: 0 time
FAF User Name: relentless

Re: AI-Uveso (v50). AI mod for FAForever

Postby Uveso » 11 Jan 2019, 03:03

Sure, you can just add a buildcondition to the platoon former like:
Code: Select all
{ MIBC, 'MapCheck', { 'Seton\'s Clutch', true } },
(If we have the map `Seton's Clutch` then use this platoon....)

This function was implemented or at least scripted by duncan to identify the map 'Seton\'s Clutch'.

So yes, you can activate a build- or form-platoon dependent on the map.

That function is part of the MiscBuildConditions:
https://github.com/FAForever/fa/blob/3a3957d6387e3a9a2b659bfec7f0f288fabf5b93/lua/editor/MiscBuildConditions.lua#L437

--

[Edit]
Condition for gametime:
Code: Select all
{ MIBC, 'GreaterThanGameTime', { 180 } },
(Use this platoon 3 minutes after gamestart (until game end))

Its also part of the MiscBuildConditions.lua.
https://github.com/FAForever/fa/blob/3a3957d6387e3a9a2b659bfec7f0f288fabf5b93/lua/editor/MiscBuildConditions.lua#L387
User avatar
Uveso
Supreme Commander
 
Posts: 1274
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 46 times
Been liked: 190 times
FAF User Name: Uveso

Re: AI-Uveso (v51). AI mod for FAForever

Postby Uveso » 18 Jan 2019, 05:19

Update 18.Jan.2019(v51)

- New: Added new AI function to search teleporter targets. (Now respecting antiteleport towers).
- New: Added new buildcondition to check if a platoon has x units.
- New: Added some builders for base recovery to build energy + mass and reclaim in case of zero eco income.
- Opt: Ecomanager now only pause/unpause 1 unit per loop cycle not up to 3.
- Opt: Added debug messages in case we have a buildplatoon (customunits) assigned to a builder with lower tech level than needed.
- Opt: Reworked shield assist function for SubCommanders. (using the new buildcondition)
- Opt: Reworked nuke launcher function. (More nukes if a paragon is present)
- Opt: Fixed an issue inside the teleport platoon where units are assisting even if we have low energy.
- Fix: AI was not able to get a higher techlevel in case a paragon was prebuilded on game start.
- Fix: Excluded the ACU from any attack platoon. (ACU has it's own attack function)
User avatar
Uveso
Supreme Commander
 
Posts: 1274
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 46 times
Been liked: 190 times
FAF User Name: Uveso

Previous

Return to AI modifications

Who is online

Users browsing this forum: No registered users and 0 guests