AI Development Guide and M27AI v74 Devlog

So after trying to play with M27AI on DualGap Scale Adaptive around 2 min in the entire game freezes and I have to force kill it. This is the log I got from it game_17452319.log

@igneustempus Thanks, it looks like M27 will hard-crash on any maps that have mexes outside the playable area, I'll have it fixed for the next version

v42 Update
This update was almost entirely about fixing issues highlighted by replays people have sent me:

  • Various adjustments to Czar and Soul ripper logic to make them avoid large concentrations of enemy ground AA better
  • Various adjustments to turtling logic so it's less likely to preemptively build T2 arti, large amounts of T2 PD, and/or mobile artillery
  • Various adjustments to bomber defence logic, including expanding the cases where bombers will target enemy fixed AA buildings
  • AiX Omni vision support - When a teammate/M27AI has map-wide omni vision then intel units shouldn't get built. If the enemy team has map-wide omni vision then stealth shouldn't be used.
  • Multiple enemy TMLs and/or billy nukes should now be defended against
  • Engineers should now be able to handle enemy cloaked selens blocking mexes
  • 21 Other misc changes and 17 bug fixes, including fixing hard-crash caused by maps with mexes outside the playable area, and a bug that prevented backup logic for deciding what experimental to build from working (most relevant for unit restrictions and modded games)

Acknowledgements

  • tyne141 – Replays highlighting M27’s vulnerability to massed TMLs
  • Yung Dookie – mentioning they were practicing against M27, which meant I had a few replays I could check for flaws in M27’s approach
  • Radde – A number of replays highlighting flaws in M27’s turtling approach
  • Splitice – Highlighting M27’s issues with not building many experimentals (in a modded game) and units dying to long range units.
  • IgneusTempus – Replay highlighting hard crash on dual gap

Great work! I think it can play at around 700 rating in 1v1. AI uses bombers quite well, its pain in ass to deal with them even with air control. All in all pretty solid.
I played some games with it, search "M27 testing" if you want to see them. What i noticed is: strange unit movement and questionable unit composition. For example it will build too many t1 maa while being at disadvantage. It will not contest huge concentations of reclaim (cadmium gree for example). It's pd logic is kinda bad too. Like it will build pds in base where it's not doing anything useful (regor highlands). Also its plateu logic working strange (on regor highlands it never dropped three mex expansions with civs but dropped 1 mex hills).
I think it ecoes too much maybe? On some maps it's ok but on some it snowballs quite bad.

Skill issue

@tomma Thanks for the feedback and for labeling the replays, I'll have a look to see what adjustments can be made

Various mostly unrelated changes based on replays provided:

  • Adjustments to experimentals, including adjustments to when to build, targeting/attack logic adjustments for land experimentals, improvements to Novax target prioritisation
  • Improved response to T2 bomber snipe attempts
  • On chokepoint maps reclaim should be factored into the decision of where to setup the chokepoint
  • Basic support for games where there are no enemy players (e.g. survival maps)
  • Sniperbot attack logic rework
  • Optimisation of the logic for calculating rally points (now takes c.10% as long)
  • 12 Bugfixes, 38 other Misc changes

Acknowledgements

  • Radde – a number of replays highlighting flaws in teamgames particularly late-game scenarios
  • Wingflier – replay highlighting M27’s vulnerability to a Corsair snipe
  • Relent0r – Highlighting performance concerns on Ian’s Cross, and a replay highlighting some issues on Fields of Isis 2v2
  • Tomma – Various 1v1 replays, highlighting a couple of points that could be improved on further (e.g. bomber dodging)

Could you add support for foreign engineering units (units sharing)? Now, as far as I understand, buildings and experimental units are built сonsidering of GetFactionIndex

@art-wiedzmin If you're talking about e.g. a Cybran teammate giving engineers to a Seraphim M27AI, and having the Seraphim M27AI build cybran experimentals, this is already supported. E.g. if you spawn in M27AI in sandbox, give it a paragon, and a bunch of T3 engineers from a different faction, it should build an experimental with that faction's engineers (so if you gave it Cybran T3 engineers and it had no other T3 engineers, I'd expect it to start on a monkeylord).

There are a couple of bits of logic that will be affected by the base faction (e.g. when deciding what type of experimental to build it will be assuming it has engineers of its base faction so its decision might be different to if its base faction aligned with those engineers, while some parts of the logic like building hives will also be faction index dependent) but this shouldnt prevent it from building any experimentals of the gifted faction.

V44 Update:
First part of planned improvements to teamwork (released early due to a hotfix for a rally point bug in v43):

  • Resources should be shared amongst the team
  • Resource producing buildings should be gifted to allies in some (rare) cases
  • Teammates overflowing resources should impact on other M27AI's calculation of their available resources
  • Engineers should no longer try and claim a mex that an allied M27AI is already planning on claiming
  • Teammate's air power should be disregarded to some extent if they are far away
  • Units should now try and retreat from T2 PD that hits them but hasn't been revealed yet.
  • Fixed bug that would cause M27 to think there was a safe rally point near the enemy base (leading to various unintended behaviour, such as ACUs 'retreating' into a heavily fortified position)
  • 8 misc changes and one other bugfix

Acknowledgements:
Relent0r - highlighting error message
Radde - replays showing strange decisions by m27 which were caused by the rally point bug

Latest changes (v45 summary)
This update's main focus was on teamwork although I also got sidetracked into improving PD placement logic.

  • M27 teams should coordinate which plateaus they will try and drop on so they dont all go to the same plateau
  • Land scouts for mexes should be shared to avoid doubling up
  • ACU kill targets are now coordinated even if the ACU isn't the closest one to other teammates
  • Improvements to the decision on where to build PD on maps with cliffs near the start position where M27 isnt choosing to turtle
  • Improvements to the strat bomber target selection to allow for a more seamless viewer-bombing experience
  • 19 Bugfixes and 20 misc changes

Acknowledgements:

  • Relent0r – Highlighting bug on Moonlight where M27 would incorrectly see there as being 1 chokepoint (when there were 2)
  • Fearghal – Replay containing errors and crash

Greetings
I've tried playing several maps with the latest updated, however it keeps crashing around the 5 minute mark. I disabled all other mods , it still crashed , changed maps still crashed. If you need more infomation let me know. I've not familiar with how feedback is given here.
I did see someone else managed to upload their game log, how IDK.

@savinguptobebrok Could you give me a couple of the replay IDs where the crash happens? (the earlier on the crash happens the better)

Here is the one with no mods (Uveso & m27 only)

https://replay.faforever.com/17705860

If you want the game log or crash log let me know.

Thanks, looking into it further for some reason v45 was only compatible with the FAF develop version of FAF (hence why my pre-release testing didnt pick up any issues as it was all using FAF develop). I've uploaded v46 that reverts it back to v44, and will either upload a new version if I figure out the cause of the incompatibility, or wait for the current FAF develop changes to be incorporated.

Latest changes (v47 summary)
The main focus of this update was on optimisation. Special thanks to Softles who wrote some work scheduler code that I was able to use to try and spread out some of my function calls to improve performance.

  • Fixed the bug from v45 that would cause every game on FAF standard (not FAF develop) to crash when an M27 bomber fired.
  • Added in logic for doing a simple profiling of AI performance which can be run by any AI (even if no M27AI is in the game) - for use in place of a normal AI tourney
  • Incorporating Softles' workflow scheduler to the majority of M27's loops
  • Further optimisation of functions relating to recording the units in a platoon and calculating the threat of enemies
  • Reduction in the amount of error messages displayed
  • 3 other bugfixes and 3 other misc adjustments

Overall based on my '4v4 UEF Africa for 10m' benchmark, v47 is approximately 8.5% faster than v46.

Acknowledgements:

  • Softles for providing work scheduling code
  • Savinguptobebrok and Fearghal – highlighting crashes caused by M27 (in every game)
  • Relent0r – Highlighting an issue where the ACU can build T1 power when in a vulnerable position (no change was made as it’d be too much effort for a niche scenario – essentially if all our power is destroyed, and we lack intel, then the ACU thinks there are no nearby mobile enemies and tries to build a pgen, but by that stage it will have lost anyway)

Latest changes (v48 summary)
A smaller update that should have minimal impact on how well M27 plays, yet still be one of the more noticeable updates:

  • Added 21 different messages/taunts to give the AI more of a personality
  • 9 bugfixes, including fixing an occasional crash that could happen when checking the pathing of units during the game
  • 4 misc changes, including adding support for upcoming FAF develop changes to ensure M27's bomber dodge logic continues to work

Acknowledgements:

  • Fearghal for replay highlighting a crash caused by M27's pathing check

I've still been playing against M27 with some friends. I haven't shared any replays recently because there wasn't much too noticeable for a while, but we did have a few games in a row on a map generator map in which one of the enemy ACUs just walked straight into T2 point defenses and died. I did built T2 point defenses relatively early but I'm not sure why it didn't retreat once it was getting hurt. This is the replay URL: https://replay.faforever.com/17728462 there were also a few other games on that same map where the enemy ACU did exactly the same thing and died so it seemed to be a recurring issues.

All of my games are titled TyneTest and most of them are against M27 with a few human allies and sometimes M27 allies so if you want extra random replays just search them up. Other than the one issue noted above, the M27 is still giving us novices a run for our money, we often beat it but it does often manage to beat us too by rushing experimentals or T3 artillery.

@tyne141 Thanks for flagging - the issue is caused because the ACU tries to retreat to what it thinks is the nearest safe place, but due to the simplified pathfinding approach M27 uses it doesnt realise there are cliffs that will mean the quickest path to the safe place takes it closer to the T2 PD. Unfortunately there's no easy fix for this scenario (e.g. just running in the opposite direction to the PD would cause the ACU to go to the wrong place in other scenarios).

It's been mentioned that there are plans to update the base FAF pathfinding logic so I'm holding off spending time trying to improve the approach M27 uses for now as there's a good chance I'd be switching to the new logic if it's more accurate than my current method

Latest changes (v49 summary)
Hotfix for a hard crash:

  • Fixed crash that could happen in some late-game scenarios (if a pathing check was done on a mex)
  • Fixed several issues with norush games, the most noticeable being if a hydro was near the start position but out of the norush range, it'd cause the AI to fail to build any power
  • 11 other bug fixes, including one that led to more MAA than intended being built for the ACU early game
  • 14 misc changes, including novax and T3 arti coordination refinements, norush improvements (so less mass is wasted before the timer runs out), and increasing the times where platoons will look for enemy naval units (including Seraphim destroyers)

Acknowledgements:

  • Teralitha – Replay highlighting a hard crash caused by M27, along with various issues with norush
  • Uveso – flagging Teralitha’s replay for me to look at and noting the error code involved was the same as one given when hives are given a move order
  • Sorrydough – suggestions on improvements and replay highlighting M27 barely winning a 3v1 on a small map
  • Tyne141 – Replay highlighting ACU suiciding into PD – unfortunately this was due to pathing issues so no solution could be found.

I've noticed one major vulnerability on many maps that have water in between the AI and player like Flooded Strip Mine: the AI almost always sends the commander through the water towards the enemy fairly early on in the game, it's very very easy to destroy the commander with torpedo bombers because the commander is virtually undefended and cannot get back out of the water in time; my impression is that the commander is programmed to harass early on, but in the case of a map like Flooded Strip Mine, it takes so long to get across to the enemy that the commander can very easily be destroyed with torpedo bombers by the time it gets in the water. The commander isn't much of a threat if it get across to the opposite island at that stage in the game anyway so I think it's quite a risky move for very little reward. Here's an example match: https://replay.faforever.com/17901355