AI Development Guide and M27AI v74 Devlog

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

@tyne141 Thanks, I'll see if I can make it a bit more timid on larger maps where it has to go through water to get to the enemy (as well as if there's anything I can do about the lag/stuttering which I expect is pathfinding related)

v50 - Navy is here!
Introduced navy logic for each faction, including:

  • Figuring out if it wants to consider going for navy on a map, and if so where to locate its factory
  • Deciding on the best time to go navy
  • Producing a range of naval units (no shield boats or stealth boats yet though)
  • Utilising different tactics based on the naval state
  • Per-unit dodge micro (to help survive battleship and Aeon destroyer shots)
  • 7 bug fixes and 5 misc changes. One of the biggest behind the scenes changes is a cap on how long M27 will spend rechecking pathing, which should solve issues on some maps that would cause it to pause for a couple of seconds regularly

Despite both the addition of a whole new field of war, and individualised microing of units, M27 runs faster than the last update (which I think will be due to the cap on pathing checking time).

Note that navy is a very tricky area for AI (one of the reasons I've held off introducing it and focused on niche areas from v37 onwards), and this is only the first version of the logic so I expect in some cases it will be worse off than before as a result of this.

Acknowledgements:

  • tyne141 - Replay highlighting ACU's vulnerability to torpedo bomber snipe

@maudlin27 - example of navy game: I've played a few games with navy now and it seems to be working well. In a few games it has used the missiles on the cruisers to great advantage. Here's a Setons game I just played with 7 M27AIs + me and it seemed to work well; I didn't notice any major mistakes made by the AI; however, two of my opponents commanders were killed on the land bridge by the M27 opposition so they were maybe being a bit too reckless with their commanders: https://replay.faforever.com/17979113

V51 released but I'm holding off summarising the changelog for now as I may need to roll back to v47 and scrap the various changes made since then.

A few different players have reported desyncs happening sometimes when playing M27 with more than one human player. If you come across this, please could you send me the replay, and also let me know the last version of M27 you played multiple such games (i.e. games with 2+ humans) on so I can try and figure out which version caused the desyncs to start happening.

So far I've seen it happen from 3m into a game to more than 1 hour into a game, on a variety of maps and gamestates.

v51-52 - Navy enhancements and desync fix

  • Hopefully fixed a desync that would occur frequently when more than 1 human played a game with M27AI
  • 10 other more minor bugfixes
  • 9 enhancements to engineer build logic e.g. making them and ACUs start construction sooner, and improving the initial build order (most noticeably when trying to go second air)
  • 30 enhancements to naval related logic (including air responses to naval threats), the most significant being a shift in the 'all out' naval attack logic to decide for each unit whether to attack based on its range (so e.g. a force of 5 destroyers and 1 frigate vs an enemy force of frigates should no longer suicide the 1 frigate into the enemy if they're out of range of it)
  • 3 other misc changes

Acknowledgements:

  • Relent0r – replay highlighting naval game; Alterting me to the desync issue along with several replays
  • Theodorex – Noting issues with M27 when T2+ units are disabled.
  • Tyne141 – Game vs M27 on Setons
  • GreatShrek – noting they’d suffered a desync (would’ve been nice had it been via a message not a review, but their replay made it viable for me to find and fix the desync, as it gave a map where desyncs happened almost every time early game making frequent testing of changes viable)