AI Development Guide and M27AI v35 Devlog

3

v24 Update
The main focus of this update was having the AI rush bombers more often and various other changes to the air logic:

  • T3 bombers will sometimes be rushed depending on the map and game state (e.g. on 'island' maps)
  • Improved targeting for bombers, in particular when targeting enemy structures and considering whether to attack a shielded target (particularly relevant for strategic bombers who previously would ignore any shielded target)
  • Various tweaks to build orders and whether to upgrade an air factory in preference to a land factory
  • Various bugfixes

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

2

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:

  • Building sonar on island maps
  • Guncom ACU considers targeting high value locations instead of just going for the enemy base
  • More factories and engineers are likely to be built earlier on
  • Minor adjustments to bomber targeting logic

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

2

V26 - Nukes, shields and novax
This update was aimed at increasing variety in the late-game (I'm basically working through the late game units I want my AI to try and build one by one).

  • Nuke launchers will be built late-game if the enemy doesnt have SMD, and aborted if the enemy gets SMD in time
  • Shield generators will be built to protect high value structures (although the Cybran's mostly for show since it builds the T2 rather than T3 shield most of the time)
  • UEF will build and use a novax centre in some cases
  • Various misc changes and bug fixes (12 bug fixes, 24 misc changes), including things like having factories self-destruct, multiple mass storage queued at a time, and better logic at avoiding trying to queue multiple buildings in the same place.

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

3

M27 turns 27!

Main change in v27: T3 arti introduced
Other changes: 23 bugfixes, 38 misc changes.

I was expecting the T3 arti to be relatively straightforward since I already had logic for choosing a nuke target that I could adapt, but getting the power adjacency to work became a real headache and also led me to a separate bug where structures could be built ontop of each other (thanks to Jip for confirming it's an engine bug).

The other bugfixes and misc changes included various updates relating to replays people helpfully provided:

  • Improved AI's ability to fight ghetto gunships (thanks to Babel for the replays highlighting this weakness)
  • Reworked overcharge logic (I'd originally written it when M27 could only build T1 units so there were a few flaws with it when fighting T2+ units)
  • Introduced a unit cap for ASFs (thanks to Azraeel for the replay highlighting 2 M27 AIs building c.900 asfs! and Fearghal for confirming a similar issue on the Air Wars map)
  • Fixed a hard crash that sometimes could happen at the start of the game. Also removed an amusing bug/feature where the Ythotha deathball would be controlled by the AI making it far deadlier (thanks to Relent0r for highlighting both of these)

Edit: Also managed to introduced a painful new bug - the ACU will now suicide into enemy PD (due to the new overcharge logic) - this will be fixed in the next version.

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

2

V28 – The compatibility update

This update was mostly focused on making M27 compatible with a wider range of game options. In particular, it should work far better on the following:

  • Non-assassination game modes (previously it would stop working altogether when its ACU was killed, or all enemy ACUs were killed)
  • No rush game option
  • Unit restrictions (only to a limited extent)
  • Maps where amphibious units can’t path to the enemy base
    Other notable changes:
  • Improved use of nukes (will consider if there are any valid targets that avoid SMDs rather than just assuming the SMD counters the nuke, while more targets will be considered initially and checked against SMD locations)
  • 19 Misc changes, 12 bugfixes (most notable being the one where the ACU would suicide into T2 PD)

Some of the changes to enable this compatibility involved a rewrite of numerous different sections of my code, given how up until now it’s been written on the assumption that if the ACU dies it wins the game, so it’s possible I’ve introduced a bunch of bugs and/or not all the changes introduced will work properly!

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

1

v29 - Optimisation and TMD
I spent the majority of this update trying to optimise some of the more intensive parts of the code, although the limitations with the profiling options meant it was hard to assess how much benefit this has:

  • Optimised logic relating to reclaim even more, in theory with an improvement in accuracy/responsiveness
  • Optimised platoon logic for raiding mexes, with a loss of functionality that I'm hoping might be more a benefit than a disdvantage (when originally written raiders would travel near friendly mexes on the way to the enemy mex - this was before my threat detection logic from ages ago so in theory this is less needed and in some cases is bad due to delaying the raiders)
  • TMD should now be built
  • Anti-mercy logic to help protect ACU from snipes
  • 4 Bug fixes (ACU should be slightly less aggressive, while there should be far fewer errors when running total mayhem mod) and 8 Misc fixes

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

2

v30 - Czar, Soul ripper and Defences
A bunch of new units unlocked/added this time, to varying degrees of depth. I'd originally hoped to have all the experimental air options added with this version, but I ended up getting sidetracked by some TMD building bugs which took far longer to resolve than I'd hoped (and included needing to rewrite parts of my engineer code), so Seraphim will have to wait.

New units that the AI will build and use:

  • Czar and Soul ripper
  • Static AA defences
  • Static PD and walls

Other changes:

  • Improved anti-cybran cloaked laser com logic
  • Improved fatboy logic
  • Reworked reclaim approach (again!)
  • ACU should run from experimentals much sooner
  • 23 Other misc changes and 9 bugfixes (including an unintended feature where the AI would get a 4-5s headstart in every game, and various bugs with building TMD)

The PD and AA buildings aren't anything fancy at the moment as this isn't meant to be a turtle AI (yet...).

Thanks to Azraeel for providing a number of replays which flagged certain issues (making me accelerate planned fatboy changes, and also highlighting M27's vulnerability to a cloaked laser com) along with providing some very entertaining moments, Babel for highlighting the 5s benefit M27 was getting at the start, and Fearghal for highlighting the vulnerability of the ACU to experimentals.

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

2

v31 - Bombers and TML
The main focus of this update was a rewrite of most of my bomber targeting logic and use of the Ahwassa. This took a bit longer than other updates in part because I had a week away.

  • Ahwassa can be built by Seraphim
  • Bomber targets are now determined based on the bomber tech level (previously the current Air factory HQ was used as a proxy with all bombers assumed to be the same tech level)
  • New engi hunter targeting mode for early bombers
  • Bombers should avoid targets protected by static AA ((previously they'd only avoid if the AA was near the target itself)
  • Introduced hover-bombing, mostly for strats and Ahwassa
  • Strats will launch co-ordinated attacks to try and take down more heavily defended targets
  • TMLs can now be built
  • 12 Bugfixes (including one causing massive over-production of engineers at the start of the game)
  • 37 General misc changes
  • 17 Further misc changes focused more on late-game (e.g. refining the logic for what experimental gets built, and how certain experimentals are used)

Some of the misc changes resulted from feedback/replays provided by people. In particular thanks to the following for this version:

  • Chp2001 – I almost gave up on getting hover-bombing to work, but Chp2001 shared code they’d used that achieved hover-bombing. Although I couldn’t get that code to work, it gave me better motivation due to knowing it should be possible for an AI, and a better steer on some of the timings - even after this I had so many failed attempts I was going to give up on my last attempt (which ended up working), so had it not been for Chp2001, there'd be no hover-bombing in M27AI as I'd have given up far sooner and needed more attempts to get there.
  • HintHunter – replays highlighting poor early-game performance including heavy mass stalling and engi-overproduction
  • Relent0r – highlighting poor performance on Selkie Mirror vs Sorian Air (on running the map I realised one reason was a bug with the pathfinding I used that led to 2 mexes being ignored)
  • Azraeel – Replays showing a number of late game flaws and issues when dealing with units on a plateau
  • Babel – Notes on ACU being too aggressive, and M27's vulnerability to enemy air if it doesnt scout the air fac in time (M27 now gets a couple of inties preemptively to support its bombers while its ACU is far more likely to fall back when ahead on eco)
    (apologies if I've missed anyone off - as it's been a longer update cycle I've lost track of the reasons for some of the changes)

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

1

v32 - Plateaus
The main focus of this update was introducing Plateau logic – on maps that have mexes that can’t be reached from the starting location, M27 should sometimes send engineers there with a transport. This effectively required the creation of a mini-M27AI to operate for these plateaus, with the following all being done:

  • Logic for identifying the plateaus, and deciding whether they’re safe to send a transport to
  • Building the transport
  • Loading engineers into the transport
  • Sending the transport to the plateau to land the engineers
  • Having the engineers decide on appropriate buildings to get (e.g. building mexes, land factories etc.)
  • Having factories on plateau decide on appropriate units to get
  • Disabling parts of the main M27AI logic that wouldn’t be very good on Plateaus (e.g. avoiding upgrading plateau factories to T2 unless there are no other options)
  • Having specialist logic for any units build by factories on a Plateau, to only consider targets on the Plateau. This involved different platoon AI logic for scouts, MAA, indirect fire units, and direct fire units, along with disabling parts of the main M27AI logic (e.g. for scouts and MAA)

Given the extent of the Plateau changes there will likely still be a few bugs relating to this.

Other changes:

  • 15 Bug fixes, including various issues with TML (they would rarely be built; get built in the opposite direction wanted; and could lead to a crash in the game), and a bug that could lead to 5+ experimentals being built simultaneously.
  • 44 Misc changes, mostly relating to use of air units, with some relating to building engineers.

Thanks to:

  • Relent0r – Replay highlighting bug that caused 5 fatboys to be built simultaneously and vulnerability of M27’s bomber defence to enemies building shielded flak near to M27’s base, along with general suggestion to have hover-bombing not apply if flak detected. Strategic flaw with having M27 ctrl-k all T1 factories at once when it thinks it doesn’t need them.
  • !MarLo - Providing several screenshots and replay highlighting issues with M27 having >300 strats idling

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

1

v33 Hotfix

  • Fixed a number of Plateau related bugs that resulted in issues where the Plateau had 3+ mexes
  • Fixed bug causing bombers (in particular T1 bombers) to not work properly when in defence mode
  • Various other bug fixes (23 in total including the above 2 points), including Czar targeting issues, MAA not being built for experimentals, and SMDs not building more than 2 missiles.
  • 36 misc changes, including making it less likely M27 will overflow mass, and improvements to special T1 bomber engi and mex hunting logic.
  • Misc changes included tweaks to the logic for building PD to make the AI build more of them (originally intended as part of a larger update to have the AI make firebases in some rare situations, but this part was postponed due to the number of bugs that needed fixing).

Thanks to:

  • Pyrolol – Highlighting issues relating to Plateaus on Open Palms
  • Relent0r – Highlighting a bug with the bomber defence logic and Plateau issues on Open Palms, along with replays showing a Czar targeting bug, and bug with sending MAA with experimental units
  • Fearghal – Replay highlighting SMD not unpausing after firing its missile (when 2+ missiles had been built)

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

1

v34 - Dynamic firebases

  • This update introduces firebases, although the scenarios where they get built will be relatively rare. More extensive turtling logic is planned for a future update (specifically pre-planned firebases), but for now M27 has what I'm calling 'dynamic' firebases, which in practice are likely to be built if it faces a constant stream of progressively stronger enemy units. As part of this, it will now build T2 artillery for the first time.

  • Another related change is the introduction of shield assist logic to help with T3 arti wars, with M27 being significantly better at surviving against a T3 artillery.

  • 15 Bug fixes, including an issue that stopped torpedo bombers working (they'd only attack enemies that got near them previously), and an error that would happen when building experimentals if the enemy had an experimental

  • 33 misc changes, including improving ecoing ability slightly by trying to always have something upgrading (sometimes this can hurt it though)

Thanks to:

  • Pyrolol for highlighting a bug with Plateaus on Twin Rivers
  • Relent0r for a bug with the decision on what experimental should be built.

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

1

v35 - pre-planned firebases
Part 2 of my turtling logic - this time M27 will preemptively setup a firebase at map chokepoints. It only works on very simple chokepoints (e.g. Astro and Fields of Isis; there will be a number of other chokepoint maps which it doesnt detect/work on), and I'm not even sure if it is beneficial even on these maps (it has a slight boost in performance against AI but that's to be expected as most AI will suicide units into the firebase - for example it was sometimes able to beat DilliDalli AiX 2.0 on Astro Craters. It's eco performance suffers massively from spending so much on the firebase though)

Other changes:
24 Bugfixes, including

  • Novax and T3 arti targeting (Novax would go to a unit's original position; T3 arti could sometimes error out when selecting a target)
  • Fatboy run logic (that'd cause them to flee in terror from the slightest enemy threat)
  • Issues with the power-stall manager, in particular a miscalculation of the energy usage of SMD and SMLs
    22 Misc changes, including:
  • Air factory builder tweaks so air scouts are more likely to be built, and so the air factory and intie should be rushed if enemy air units are detected early in the game
  • Making ACU more aggressive if the enemy doesn't have T3 units

Acknowledgements:

  • Jip – Replay that resulted in an error relating to a land factory being built on a plateau where the pathfinding didn’t work.
  • JantDarvus – replay highlighting M27’s vulnerability to early jesters
  • Relent0r – highlighting issue with fatboys retreating, and issue with Ythotha’s attack-moving (I’ve decided to park the Ythotha point as a potential future change as I think I want experimentals to attack most of the time, except when there’s a Ythotha death-ball nearby)
  • Spyro – Replay where M27 may have caused a hard-crash (It's not clear from analysing the replay if M27 caused the crash or if it was a separate occasional error that happens with FAF where M27 isnt active, but the replay highlighted a few errors/issues)

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