AI Development Guide and M27AI v20 Devlog

1

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.

  • Implemented new profilers (both my own, and one Softles kindly provided) to help identify high usage functions
  • Rewrote most of the reclaim logic to improve performance (significant reduction in game stuttering, although still worse than I'd like)
  • Optimisation of a number of other functions to significantly reduce time taken
  • Improved SMD logic (including fixing a bug that meant SMD was never built) - AI is now much more likely to have a loaded SMD ready before a nuke hits.
  • Tweaks to how much power and energy storage is built to reduce tendency to over-build power and to ensure the ACU can deal 15k damage with overcharge late-game
  • Various bugfixes (notable ones being a bug with ACU escorts that would result in lots of errors appearing in the log, and an issue that caused escorts/assisting platoons to sometimes go to the wrong location)

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v20-devlog/41

0

@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.

0

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

0

@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 developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v20-devlog/41

0

@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

0

@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 developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v20-devlog/41

1

v16 - Hotfix:

  • Rewrote my land scout pathing logic to fix a bug that caused a crash on Liberiam Battles (thanks @splitice for flagging)
  • Minor tweaks to overcharge logic to increase the units that will be considered
  • Low health enemy ACUs are more likely to be targeted for an all-in attack even if M27's ACU isn't nearby
  • Bugfix to air threat logic so that air units near the ACU are correctly prioritised; also tweaks to the logic for building air factories when outnumbered in air

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v20-devlog/41

0

@maudlin27 Re; Burial Mounds if I was to describe the problems with the strategy they would be (in no particular order) - sorry was late.

  1. Over reliance on light artilery. I (a human player) would see this and respond with a small air fleet and this unit is not particularly useful on a water map. The AIs pumping these out were largely limited to defensive operations.
  2. After the early rush fails (or if AI suspects it will fail) the AI really needs to switch to economy building first. A player who has a well optimized build queue can easily push many orders of magnitude ahead of this AI
  3. One of the AIs didnt build any mass extractors, just a single land factory and pumped out units. Given the extremely low cost and quick pay back time of a T1 mass extractor I struggle to see why they should b skipped (of course they could be delayed, but I stopped the game after ~15m and it was still just pumping out units). Perhaps if a early rush tactic is chosen a max game time before mass extractor build within at-least the players own area continues should be implemented?

I havent played against the AI as a human yet so this is theoretical.

0

@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.

0

@splitice Thanks for the feedback!

  • Re 1 - Likely a flaw due to the civilian point defences - the AI treats civilian units as enemies, considers the total weighting of enemy units, thinks its up against an enemy who favours PD far above mobile units, and so builds lots of arti in response. No easy short term solution where the civilian base cant be pathed to (I'd probably need to come up with map specific logic which will be a long way away, or special rules for civilians which would similarly be very low down on my list as this is the largest civilian base I've come across on a map to date)
  • 2 - Unfortunately it's not straightforward to come up with an approach/set of rules that would handle this well, and the current approach assumes it should be able to gain map control if it spends more than the enemy on units.
    Longer term I'm planning on introducing turtle logic to the AI which I'd probably look to use on a map like this which would make it eco a bit better, but that's at least a few versions away.
  • 3 - Sounds like a bug - doing a quick test with 8 M27AI, within the first 5m all mexes on each side were either claimed or queued up to be claimed, so I'd need a replay to investigate further. When checking back on the 4v4 test I ran though I noticed some other bugs which led to a massive slowdown/broken AI after certain players died which I'll be looking into for another hotfix!

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 developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v20-devlog/41

1

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:

  • Bombers will try and defend the base if enemies get near
  • ACU will overcharge when retreating
  • Air factories should be built in priority to land factories if there's a significant air unit shortfall
  • Various minor bugfixes (mostly aimed at reducing the error messages appearing in the log when an ACU dies)

Edit: v18 Hotfix - AI should now work when DilliDalli AI is also playing; also fixed issue for maps with >=10 players.

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v20-devlog/41

1

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.

  • New air dominance strategy - if the enemy fails to get AA quickly enough the AI will aim to focus all its resources on building bombers to overwhelm them. Related to this I've reworked some of the logic for choice of bomber targets
  • Better use of rally points - units will look to gather at a rally point between our base and the enemy, so they are less likely to cause pathfinding issues at base and can respond quicker to threats
  • Improved logic for ACU upgrades - fixed some bugs and added new checks so ACU should be less likely to upgrade when near the enemy base, while upgrading sooner if its able to, and attacking the enemy sooner once upgraded
  • Various other bugfixes and minor tweaks

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 developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v20-devlog/41

2

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.

  • Experimental units will now sometimes be built late game
  • Improved use of T3 mobile artillery (they're less likely to gather in huge numbers doing nothing...)
  • Better use of heavily upgraded ACUs (including bugfix that caused Cybran ACUs to do nothing after getting laser)
  • Tweaks to Engineer management
  • Other minor bugfixes

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v20-devlog/41