@maudlin27 said in AI Development Guide and M27AI v14 Devlog:
ACU will now consider Ctrl-King itself
How does it evaluate this in practice?
edit: I just noticed the text above that it is a 'secret'.
@maudlin27 said in AI Development Guide and M27AI v14 Devlog:
ACU will now consider Ctrl-King itself
How does it evaluate this in practice?
edit: I just noticed the text above that it is a 'secret'.
A work of art is never finished, merely abandoned
Really interesting document. I look forward to seeing this grow.
A couple of things I didnt find (I may have missed):
Theres a fair bit of talk of CPU performance but I didnt see any direct evidence of what causes the slowness. While its great to have optimal functions knowing where to direct attention (low hanging fruit!) is a good idea.
@splitice
1 - Re % of an AI's time taken on different areas, It will vary depending on the AI and the approach taken, although at a high level I'd expect pathfinding to take up a lot of time at the start of game, and build conditions to take up minimal time throughout the game.
For example with pathfinding, for a while my AI would calculate if it could path somewhere as and when it needed to (and then record the result so it could refer to later), but more recently it will do the calculations up-front, which is consistent with the approach of the other AI I'm aware. Times taken can vary dramatically - e.g. when Balthazar was testing their pathfinding logic, I think the slowest time they came across was on Alaska (which I'm guessing was an 81km map) where it took more than 5m. Softles mentioned their pathfinding after optimisation is down to 0.4s on smallest maps. Map size has a big impact though, since an 81x81km map is 262 times the size of a 5km map, so if you do things to the same level of accuracy the time taken will skyrocket.
Therefore pathfinding is largely a 1-off cost at the start of the game (where it's more acceptable to have a slight delay before the game actually starts), although there'll still be some overhead later on (e.g. if trying to calculate a safe path to use - I dont use this logic at the moment so can't comment on how much time it takes).
The most useful function for working out the CPU performance impact is GetSystemTimeSecondsOnlyForProfileUse()
If you compare the result before and after a 'heavy duty' function you can get an indication of how long that function takes (although the figure isn't that reliable).
In the latest version I'm working on I'll be including lots of comments and profiler outputs from some profiling I did of my own AI in an effort to improve its CPU performance, and the code for this as well as code Softles recently helpfully shared on the AI discord for profiling will be included as part of the AI.
As a very rough guide though, anything that is running >10k times in a single tick needs to be streamlined to avoid a performance impact. Simple checks like if a variable is true or false take up no noticeable time (you'd need to be checking millions of times in a tick I'd have thought to impact things), while more involved checks such as getting all units of a particular category within a certain distance of a point on the map will take far longer.
Examples of things that can end up overloading a tick could be carrying out logic on every part of the map (e.g. calculating reclaim), or recursive logic (e.g. in v14 and earlier I'd recursively look for units around an existing unit, and then units around those, and so on, in order to group them into an 'army' to be dealt with).
To give a rough idea of the relative weightings for M27 (other AI will be different) for different aspects of the AI, the following benchmarks are for the total time taken in the first 10m of a 3v3 M27AI game on a 10km map (WIP v15):
The times are a relative guide, not absolute, as the GetSystemTimeSecondsOnlyForProfileUse() isn't that accurate, and depending on how its used it won't factor in time taken by the wider game engine as a consequence of the AI's code.
2 - Not in the immediate future, but probably once I've achieved some other goals. I think Softles may be planning an AI tournament with norush at some point so that might prompt me to have a look at it!
M27AI and M28AI developer; Devlogs and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
https://forum.faforever.com/topic/5331/m28ai-devlog-v112
v15 Update:
Focus of this release was (CPU) optimisation, so the major changes are 'behind the scenes'. It also means in some areas (primarily threat detection) my ACU unfortunately is a bit more stupid than before, as I didn't feel I could justify the increased CPU load caused by a more accurate method.
M27AI and M28AI developer; Devlogs and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
https://forum.faforever.com/topic/5331/m28ai-devlog-v112
@maudlin27 said in AI Development Guide and M27AI v15 Devlog:
Rewrote most of the reclaim logic to improve performance (significant reduction in game stuttering, although still worse than I'd like)
I'm not sure if it will help but I recently re-wrote AutoReclaim (dwm) as "AutoReclaim (splitice)" for more performant reclaims (for T!-3 engineering type towers).
--
I also tried a 2v2 (far slots) on Burial Mounds and noted many issues (including a general lack of awareness of the no unit paths and lack of serious economic growth). This was on v14. I think I'll re-asses though when this gets more mature.
I also gave v15 a try but failed on start with:
info: playable area coordinates are { 0, 0, 1024, 1024 }
info: Offmapareas are {
info: { x0=-100, x1=1124, y0=-100, y1=0 },
info: { x0=-100, x1=1124, y0=1024, y1=1124 },
info: { x0=-100, x1=0, y0=0, y1=1024 },
info: { x0=1024, x1=1124, y0=0, y1=1024 }
info: }
warning: false\000M27ERROR GameTime 1: Exceeded max loop count; iCurIntelLine=6
warning: stack traceback:
warning: [C]: in function `assert'
warning: [C]: in function `pcall'
warning: ...nder forged alliance\mods\m27ai\lua\m27utilities.lua(45): in function `ErrorHandler'
warning: ...er forged alliance\mods\m27ai\lua\ai\m27overseer.lua(387): in function `RecordIntelPaths'
warning: ...er forged alliance\mods\m27ai\lua\ai\m27overseer.lua(4108): in function <...er forged alliance\mods\m27ai\lua\ai\m27overseer.lua:4042>
warning: false\000M27ERROR GameTime 1: Exceeded max loop count; iCurIntelLine=7
warning: stack traceback:
warning: [C]: in function `assert'
warning: [C]: in function `pcall'
warning: ...nder forged alliance\mods\m27ai\lua\m27utilities.lua(45): in function `ErrorHandler'
warning: ...er forged alliance\mods\m27ai\lua\ai\m27overseer.lua(387): in function `RecordIntelPaths'
warning: ...er forged alliance\mods\m27ai\lua\ai\m27overseer.lua(4108): in function <...er forged alliance\mods\m27ai\lua\ai\m27overseer.lua:4042>
warning: false\000M27ERROR GameTime 1: Exceeded max loop count; iCurIntelLine=8
warning: stack traceback:
warning: [C]: in function `assert'
warning: [C]: in function `pcall'
warning: ...nder forged alliance\mods\m27ai\lua\m27utilities.lua(45): in function `ErrorHandler'
warning: ...er forged alliance\mods\m27ai\lua\ai\m27overseer.lua(387): in function `RecordIntelPaths'
warning: ...er forged alliance\mods\m27ai\lua\ai\m27overseer.lua(4108): in function <...er forged alliance\mods\m27ai\lua\ai\m27overseer.lua:4042>
warning: false\000M27ERROR GameTime 1: Exceeded max loop count; iCurIntelLine=9
Map: Liberiam Battles
@splitice said in AI Development Guide and M27AI v15 Devlog:
Liberiam Battles
What were the game settings, in particular what player slots were in use by what teams and/or do you have a replay ID? I tried it just now in slots 1+2 and didnt get an error but from the log extracts and look of the map it might depend on what the player and team setup is.
M27AI and M28AI developer; Devlogs and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
https://forum.faforever.com/topic/5331/m28ai-devlog-v112
@maudlin27 said in AI Development Guide and M27AI v15 Devlog:
What were the game settings, in particular what player slots were in use by what teams and/or do you have a replay ID? I tried it just now in slots 1+2 and didnt get an error but from the log extracts and look of the map it might depend on what the player and team setup is.
From memory was a mix of Sorian and your 2x m27 aix v 2x sorian aix v 2x sorian aix v1(player)
Just added m27 on a whim so didnt record game settings. Replay is https://replay.faforever.com/16044970
@splitice Thanks, found and fixed the issue in the latest version (will upload in a moment). Re Burial Mounds, having a look at the map it's not one that my AI will fare very well on at the moment (confirmed by it losing vs Sorian Adaptive when I tested just now). The biggest issue being the heavily fortified civilian base which will stop some of the ACU rushes that M27 relies on to gain an early game advantage (and which probably is also why it's not ecoing quickly), as well as making its current reliance on land for victory late-game flawed since amphibious tanks dont fare well against significant PD fortifications.
M27AI and M28AI developer; Devlogs and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
https://forum.faforever.com/topic/5331/m28ai-devlog-v112
v16 - Hotfix:
M27AI and M28AI developer; Devlogs and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
https://forum.faforever.com/topic/5331/m28ai-devlog-v112
@maudlin27 Re; Burial Mounds if I was to describe the problems with the strategy they would be (in no particular order) - sorry was late.
I havent played against the AI as a human yet so this is theoretical.
@maudlin27 said in AI Development Guide and M27AI v15 Devlog:
To give a rough idea of the relative weightings for M27
Thank you for the time you spent gathering this.
That's quite a low % of total time, I assume this is pegged at 100% (i.e max sim speed until saturation)?
In retrospect I wonder what % of time goes to AI vs lua game logic vs engine. I'd always assumed the AI code (being there is multiple instances of it running and they typically can be quite intensive) would be a good (50+%) of the total sim time.
@splitice Thanks for the feedback!
Re the low profiling, I think the low % of total time is due to the limitations of the method I'm using - while getting the difference in system time seconds gives a good guide of how long a function takes relative to other functions, I think there're other things that happen in the background as a result of the code which don't get picked up (e.g. Sprouto's mentioned there's a garbage collector that can require resources to deal with clearing redundant variables) - these could be linked to the AI, or the normal game engine/operations, and I'm not sure of a reliable way to quantify. However I'd also assume the AI will take a majority of the total sim time, especially where multiple AI are used.
M27AI and M28AI developer; Devlogs and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
https://forum.faforever.com/topic/5331/m28ai-devlog-v112
V17 Hotfix (Hotfix to the previous hotfix)
My previous hotfix fixed an issue with the AI not working on some maps, but caused it to crash on some teamgame maps. This is now fixed so hopefully it works on almost all maps.
Other minor changes made:
Edit: v18 Hotfix - AI should now work when DilliDalli AI is also playing; also fixed issue for maps with >=10 players.
M27AI and M28AI developer; Devlogs and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
https://forum.faforever.com/topic/5331/m28ai-devlog-v112
v19 Update:
The focus of this release was implementing a new 'air dominance' strategy intended to punish players who don't get AA, and to make better use of rally points.
The air dominance strategy is mostly a 'win more' strategy, but I've seen a few games my AI has played (both against humans and AI) where it has an initial bomber that does a lot of damage before being shot down, yet eventually the enemy is able to recover from the damage and wins the game. The hope with the air domination strategy is that such games turn into a quick win instead of just a moderate advantage. However it has its risks, since it's incredibly mass efficient to counter air units that are attacking your base, and if you kill them you then benefit from all their wrecks.
M27AI and M28AI developer; Devlogs and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
https://forum.faforever.com/topic/5331/m28ai-devlog-v112
v20 Update:
This version improves some of the AI's late game ability, both fixing an issue that led to severe under-utilisation of T3 mobile artillery in some cases, and having it build experimental units.
M27AI and M28AI developer; Devlogs and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
https://forum.faforever.com/topic/5331/m28ai-devlog-v112
v21 Update
This version focused mostly on smaller eco gains so when my AI is trying to eco it should do it a bit better. Main changes are:
Since my ACU self-destruct logic hardly ever triggers (I've only had it work in sandbox when testing it), I also decided to expand the behaviour - now my engineers and mexes should also exhibit self-destructive behaviour.
@jip FYI re your query a few versions ago when I introduced it, my ACU should only self-destruct in the niche scenario where it is about to die anyway and the enemy ACU is within range of the explosion and low enough health to die to it. I didn't want to risk a more general 'I give up' type logic both for fear of hit going horribly wrong, and since even in games where my AI's base has been destroyed it's sometimes managed a win with its ACU.
M27AI and M28AI developer; Devlogs and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
https://forum.faforever.com/topic/5331/m28ai-devlog-v112
v22-v23 Update
There was no particular theme to these changes, other than that most of them arose from watching mistakes my AI made on a 1v1 against another AI on Burial Mounds
Although there was no big area of focus with this release, I did manage to achieve one of my long term goals with it, beating gunner1069 (the human sparring partner who usually plays a match against each version of the AI; they're a 1.1k global from playing astro exclusively, with their preferred tactic being to turtle - originally they played M27AI on Theta Passage, until around v10 when M27AI would fare well against their turtling on conventional maps, at which point they switched to Astro Craters).
Winning against a turtle on Astro Craters is harder than a normal map, since the normal advice against a turtle is to avoid attacking them, out-eco them with your map control (since T1 mexes are far cheaper per mass generated than T2 mexes), and then attack with an overwhelming force. Obviously this doesn't work so well if gaining map control just means you have 21 mexes to their 19. There are still plenty of flaws with my AI that a good astro player could exploit to win, but it can now at least offer a challenge on the map against weaker players.
V23 hotfix - Thanks to relent0r for flagging - there was a bug in v22 which caused my T1 platoon formers to not work, which should be fixed now.
M27AI and M28AI developer; Devlogs and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
https://forum.faforever.com/topic/5331/m28ai-devlog-v112
v24 Update
The main focus of this update was having the AI rush bombers more often and various other changes to the air logic:
M27AI and M28AI developer; Devlogs and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
https://forum.faforever.com/topic/5331/m28ai-devlog-v112
Latest changes (v25 summary)
v25 - Misc
There was no particular theme to this update or any one big change, just lots of small tweaks and bugfixes (many of which I'd been putting off for a while due to not being major issues). Some of the more noticeable changes were:
In terms of the number of changes, ignoring hotfixes my main releases have typically averaged around 8 bugfixes and 16 misc/minor changes in addition to 1-2 significant changes/features. This version has 22 bugfixes and 64 misc changes, and was primarily aimed at clearing a backlog of small issues I'd noted to look at 'soon' from versions going back to v14.
M27AI and M28AI developer; Devlogs and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
https://forum.faforever.com/topic/5331/m28ai-devlog-v112