AI Development Guide and M27AI v12 Devlog

2

v4 changes (in reality v2, but when I uploaded the mod on its first release I had to rush out a couple of hotfixes where I'd forgotten to remove debug logic and accidently introduced a bug that affected all games!)

  • Fixed various bugs (see 3.14.3)
  • Slightly improved pathfinding performance (see 3.15)
  • New AI logic which will detect enemy threats and send units to deal with them (see 3.16)
  • New AI logic which attempts to maintain intel over the map to stop surprise attacks (see 3.17)

I've also updated the guide to reflect speed2's comments (as well as a couple of other minor points/sections, such as a bit on uploading a mod and some tests that I now run before uploading)

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

2

I am stunned.

Really good work, maudlin27!

2

v5 changes - these were mostly about the ACU, making it more aggressive and less suicidal

  • Fixed various bugs and improved some error handling (see 3.18.4)
    ACU improvements (see 3.19):
  • ACU will try to expand to high reclaim or mex locations, while building on mexes it comes across and reclaiming
  • ACU will have scout and MAA support
  • ACU tries to kite enemies it comes across
  • ACU uses manual overcharge to overcharge optimal targets

Also updated the guide slightly to add details of the AI development discord channel in FAF (separate to the main AI development discord), and a couple of common hard crash errors

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

1

v6 Hotfix - My AI broke with the recent FAF patch, so this is primarily to fix that. I was in the middle of more extensive changes so my AI is less stable than I'd like but I figured it's better than a broken one! I've also held off on updating the dev log for this release.

Main changes made:

  • ACU performs better underwater (reclaims units, tries to move to nearby land when it cant shoot)
  • Improvements to ACU overcharge behaviour (it should OC when retreating, and also positions better against enemy PD)
  • Switch to new error handling approach (orange messages now appear in the log with more detail; this also happens when any ACU dies)

Issues currently present I'm aware of (which shouldnt have a noticeably detrimental impact on performance, but will be noticeable to anyone looking at the log):

  • 'MergeLocations' error message on certain maps - should just mean larger platoons dont regroup at a midpoint before attacking
  • 'MexRaider' warning about the final waypoint - in most cases just affects which mexes are targetted (in rare cases might cause a delay in the platoon doing anything)
  • 'Stuttering'/delays in performance on certain maps (e.g. open palms)

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

3

V7 Update - T2 is now here! My changes were focused on creating my own engineer and platoon formation functionality (which took far far longer than I was expecting due to various difficult bugs - a lot of work for not much benefit), but at the end I threw in some basic upgrade logic so my AI now gets T2.

Various bug fixes. More notable ones are that the AI should work better on adaptive maps that 'hide' some of their mexes, and should be less likely to try and build on unpathable mexes
Custom platoon formation and engineer functionality. A couple of more notable features of this are that engineers now work together to build 1 building (e.g. power) rather than independently try and build 5 at once, and factor in what mexes theyre already planning to build on when choosing where to expand
Building upgrade logic - AI will now upgrade mexes and land factories (meaning for the first time T2 units can hit the battlefield!)
Load spreading of functionality to help counter the CPU performance hit of these changes
I've also updated the guide for a couple of points (e.g. including a section on events)

As before, much more detail on the changes/my thought process as I went about implementing them is in the dev log.

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

2

v8 Hotfix - Fixed a game crash that could happen if the AI lost an upgrading building (thanks to relent0r for for flagging there was a crash), along with a couple of other minor bug fixes.

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

2

v9 Reintroduced air units:

  • Air scouts are built to periodically scout locations of interest
  • Interceptors are used to help defend against enemy air attacks
  • Bombers should target enemy units of interest.
  • Air factory should be built early if there's enough power (and by a hydro if one is available)
  • Various bug fixes and small tweaks to behaviour - refer to 3.27.6 - 3.27.7 of the guide

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

1

I admire the guide / developers log that you are keeping 🙂

A work of art is never finished, merely abandoned

4

V10 - Implemented anti-turtle logic:

  • Use of T2+T3 MMLs and mobile arti to break firebases
  • Ecoing (not very well, but better than before)
  • Reduced turtle feeding

Misc changes:

  • Large bomber attack for if we end up with lots of spare bombers
  • T3 air factories can be built/upgraded
  • Support factories will be built/upgraded instead of HQs
  • Higher tier power is built sooner
  • Engineers can request guards
  • Various bug fixes (see section 3.30.2 of the guide)
  • Updated the guide with details on how to run in FAF Develop offline

My AI also has a new icon 🙂

M27AI.jpg


For anyone that's interested in the background to the last 5 versions/2 months - back at v5 I was crushed by gunner1069 (I usually get them to play a match every couple of weeks against the latest AI version) with a simple turtle strategy on Theta Passage - they didnt bother getting any mexes and instead just rushed T2 PD with their ACU and my AI had no answer despite having 4x the mass income. My primary focus in all the versions since then has been coming up with the logic that will give my AI a chance in that scenario.

Unfortunately, a relatively simple plan for a human (dont send units single-file into PD, upgrade mexes and then attack with MMLs) required a bunch of different bits of logic:

  • Checking for PD and running away from it (so the enemy isn't fed kills/mass), without running away when we're already in range of it and able to beat it (I had some frustrating to watch games where my AI would charge in at a firebase, overwhelm the shields, be about to destroy everything, before deciding to run and turning a winning position into a loss)
  • Realising there's PD when it kills our land scouts without being picked up by their radar
  • Making use of air scouts to reveal 'hidden' PD to avoid suiciding units and the ACU into the PD
  • Quickly expanding to uncontested mexes (including on enemy side of the map)
  • Focusing on maintaining map control and ecoing if faced with a turtle rather than trying to break them immediately, which in turn requires various logic for identifying if we're against a turtle, upgrading mexes, building T2+ buildings, upgrading factories, making use of support factories, etc. (I've still not got basic things done like capping mexes with mass storage)
  • Using indirect fire units to attack PD/long range enemy units while both protecting them from enemy mobile attacks, and not suiciding our own units trying to protect them

These changes also mean my AI will be worse in other situations - e.g. against a non-turtle it might choose to eco when it would be able to finish the game by pressing the attack, and it's also still poor at the mid-T2+ stage so extending the game via ecoing means it's more likely to snatch defeat from the jaws of victory. Long term though it needed to happen as a 'T1 or die' strategy only has a decent chance on 5v5 maps.

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

0

@maudlin27 Nice list of g
Changes of updates for you Ai mod, I'd like to extend you the offer it have this in a more of a cleaner formate over on the new faf wiki, if this is somtbing your interested in please send me a pm here or on the faf discord and I can set you up with a page 😀

"The needs of the many outweigh the needs of the few" - Spock

2

v11-v12 update:
The big thing I've been working on in these 2 updates is an alternative approach to pathfinding to replace my use of CanPathTo with a manual method that I can run at the start of the game and then lookup the pre-recorded results later in the game (rather than calculating pathfinding on the fly), since I figured this should be much faster.
Unfortunately I failed to factor in the consequential change this would have on other parts of my code, and while my replacement 'canpathto' check itself is much faster (especially on 81x81km maps), my overall AI is significantly slower! Since my new approach is based on terrain height differences, it will also be less accurate, so I've managed to achieve the worst of both worlds! However, it should at least be easier to get some CPU performance gains in the future, even if my first attempt has failed.

Various misc changes:

  • Significant improvement in ecoing speed, including the ability to build mass storage
  • MAA and Engineers shouldn't be overproduced as much, and certain T3 MAA shouldn't be treated as land attack units
  • Mobile artillery should attack enemies (instead of changing their mind every second)
  • Surplus engineers should reassess what they do periodically instead of assisting the same factory
  • Minor improvements to building and upgrade decisions to deal with mass overflow and power stall
  • SMD can now be built in response to a nuke threat
  • AI will now stop ecoing if it detects certain experimental threats
  • Various other bug fixes and smaller tweaks to the AI

See 3.34.3 - 3.36.6 for details of the changes and the journey I went through getting an alternative pathfinding logic to work.

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