AI Development Guide and M27AI v74 Devlog

@tyne141 Have you got the replay ID? Those error messages are expected with M27 if an ACU has just died (and sometimes happen at the point a game is closed down), although it's still possible that M27 is connected to the crash

v59 - Gunships

  • Unlocked gunship usage for M27 and incorporated special micro logic to improve their survivability
  • Various changes aimed at slightly decreasing vulnerability to T1 bomber snipes
  • Improvements to logic for killing underwater ACUs
  • Various improvements to make M27 respond better to nearby enemy firebases (i.e. if the enemy gets a firebase in range of M27's core base)
  • 8 other misc changes and 6 bugfixes, including improvements to M27's T1 bomber defence when faced with lightning tanks


  • Tyne141 – Replay highlighting ACU’s vulnerability to a T1 bomber snipe
  • Azraeelian Angel – lots of replays which prompted many of the changes this version (in particular the logic for killing underwater ACUs, better T3 MAA defence, and dealing with an enemy ACU that builds a firebase to kill M27’s core base)

v60 - Naval enhancements
The main focus was improvements to M27's naval logic:

  • Navy should now respond to torpedo bombers (Cruisers trying to attack them, other navy retreating)
  • Battleships can make use of ground fire in some scenarios to hit underwater targets
  • Naval response will be based on the size of the enemy threat - no longer should M27 send its entire fleet to intercept a single T1 engineer
  • 7 other naval related chantes, including Seraphim sub hunters temporarily surfacing to fire at torpedo bombers
  • Improved skirmisher avoidance logic so they're a bit harder to kill with a guncom
  • 6 bugfixes and 8 other misc changes, including rewriting weapon prioritisation logic to fix some scenarios where it wasn't working, and adjustments to gunship logic to increase their area of operations


  • Relent0r noting M27 struggled against RNG on naval maps due to its tendency to chase down lone enemy units with its entire navy

v61 - Stats
A couple of significant changes in this update, neither of which has any impact on how M27 plays:

  • Added detailed stats profiling which can be accessed regardless of whether an M27 AI is playing in the game (i.e. the mod just needs to be enabled and the configuration option set in the code to enable the stats) - as featured in the recent AI tournament
  • Created a separate AI mod! (However this mod just uses the AI as a means of spawning ACUs for human players at different start points). It hopefully provides an extra option for people wanting to fight the AI where a single AI is too easy but multiple too hard (in addition to the more mainstream use for PVP games)

In terms of other changes (that will impact how M27 plays):

  • Added naval factory land defence logic (so enemy land units that try and attack the factory should no longer be ignored)
  • Implemented and then promptly removed IMAP functionality, and instead created my own 'M27 IMAP' logic to help strat bombers be less likely to choose a target that sends them into a cloud of enemy interceptors
  • Various improvements to naval logic (13 changes)
  • Various improvements to air logic, particularly focused on when M27 is behind on air (8 changes)
  • 6 misc changes, including a greater focus on reclaim
  • 15 bugfixes


  • Thacon – replay highlighting M27’s vulnerability when the entire enemy team focuses solely on air.

Latest changes (v62 summary)
Introduced a new land rush mode for the AI which it will sometimes (but not always) use on smaller maps to favour t1 tank spam over its more conservative/ecoing approach.

During testing overall it feels marginally weaker for M27 than its normal approach, but it managed to pull off wins in some scenarios that the normal M27 would lose to.

Other changes:

  • Various changes meant to further improve M27's response when far behind on air along with other misc changes (11 changes to air), including significantly increasing production of both asfs and MAA, and being more cautious with use of asfs
  • 4 Misc changes to naval logic, including adjusting the unit mix and focusing down mexes
  • 6 bugfixes, and 13 other misc changes, including adjustments to early game building logic for the ACU and engineers and reducing ACU's tendency to dodge (which could lead them to taking more damage since they won't overcharge when dodging)


  • Azraeelian Angel - Several replays highlighting M27's vulnerability when losing air control (and the speed with which it needs to build SMD to stop humans)
  • RottenBanana - 1v1 replays highlighting M27's vulnerability to raids and a bug with trying to raid underwater mexes
  • Deribus - replay highlighting the delayed response to building TMD at a firebase when being attacked by TML

Latest changes (v63 summary)
Various changes based on replays received, including:

  • Less likely to overflow mass at T3 stage, with a significantly faster scaling up of build power (6 changes)
  • T3 fixed arti prioritisation coupled with target variation (to avoid firing at the same heavily shielded position forever) (9 changes)
  • Air less suicidal and also better at defending high value friendly air units (18 changes)
  • Chokepoint maps - M27 will now abandon a chokepoint and revert to default logic rather than staying in turtling mode if it's chokepoint is overrun and it somehow survives, along with several other small adjustments (3 changes)
  • SAM creep logic - Basic code to have M27 try and protect mexes with SAMs if it's behind on air
  • 14 bugfixes and 19 misc changes


  • Radde - various replays, highlighting M27’s poor ability to cope with lots of mass, flaws with the turtle logic, and tendencies to suicide its air (including air experimentals).
  • Azraeelian Angel – Loads of team game replays (so many I had to defer analysing some of them for the next release!), highlighting amongst other issues the need for better T3 arti building logic
  • Spikey Noob – A number of 1v1s at increasing difficulties on badlands highlighting the ease with which M27's ACU can be killed with T1 land
  • Jip – 2v2 replay against M27
  • Relent0r – Flagging a bug in M27 that causes it to break default AI from building on mexes that are covered by reclaim.

Smaller update fixing a few bugs and adding in mass fabs:

  • Unlocked ability to build T2 mass fabs (I've not checked how it handles reaching the unit cap though, here's hoping it doesn't ctrl-K them!)

6 bugfixes, including

  • Bug resulting from the latest FAF patch that caused the Ythotha death ball/energy signature to be controlled by the AI (at the same time I've improved M27's response speed to the death ball from before)
  • Shield boats should no longer remain at the naval factory if they had lost shield at any point in the past
  • The Bjarg map should now be playable by M27 in the bottom-right start position (previously it would break)
    14 Misc changes, including:
  • MML should be far less likely to walk into range of T2 PD
  • Added new 'experimental prioritisation' builder logic for late-game (where land factories are less likely to build units to conserve mass for experimentals)
  • Slight improvements to M27's response when an enemy tries to get a firebase near M27's base
  • Slight reduction in the bomber defence range to make them less likely to suicide into enemy air

Note that updates may be smaller and/or less frequent for a bit as I mull over creating an entirely new AI, and/or testing out changes in a basic alternative AI that might then be incorporated into M27 at some future point.


  • Jip – Highlighting error on the Bjarg map where if M27 started in the bottom right position it wouldn’t work
  • Azraeelian Angel - A number of team game replays
  • Radde - Several teamgame replays

Latest changes (v65 summary)
Smaller update - I'm experimenting with smaller ad hoc updates with reduced testing for fixing issues highlighted in replays (since I'm not planning any big future changes to M27 for the time being as I'm experimenting with a separate AI to try out alternative land based logic)

11 bugfixes, including:

  • Incorrectly calculating Seraphim SACU range as their TML range (leading to strange actions from land units)
  • Skirmisher platoons (e.g. sniperbots) should be less likely to suicide (by being more likely to attack move and less likely to try and move close to a target)
  • Experimental shots such as ythotha shots will now be considered for dodging

10 Misc changes, including:

  • Adjustments to skirmisher logic, including making them run further from T2 arti, and splitting up skirmishers that are far apart into separate platoons
  • Increased the value of SMD and Nukes as targets
  • Made larger units more likely to try and dodge shots (e.g. summits should try and dodge Aeon battleships, Galactic (colossii?) should try and dodge Ythothas)


  • Radde for providing an entertaining team game replay against M27 (that also highlighted some of the bugs fixed in this release).

Latest changes (v66 summary)

  • Refinements to the logic for experimentals to dodge shots (and more generally) so they're hopefully less likely to turn around in a full circle doing no damage while being attacked
  • 7 tweaks to T3 arti targeting logic, none of which are major but which for example now assign a value to heavily shielded units (previously none was given), firing infront of mobile units, reducing the value of targets that we have fired a huge number of shots at without killing, and factoring in how long it will take for the T3 arti to turn towards the target
  • 15 other misc changes or bugfixes, a number of which relate to decisions on when units should retreat (e.g. MML running from ravagers, skirmishers running from PD, GC/Monkey/Ythotha being more likely to run from a fatboy based on how close it is)


  • Radde - several teamgame replays on both land and naval maps
  • Jip and Magge for highlighting a missing units error message that appeared a lot, and also Jip for helping me figure out how to determine which direction a T3 artillery is aiming at.

Stop making it better. It's getting too hard to beat. 🙂 I'm kidding. Your work is appreciated.

@stlng At some point! Each update lately I think just after uploading 'right, now I can take a break and focus on writing a new approach to handling land units', then I see a replay where M27 does some stupid or incorrect things and figure I'll just put through one more update to fix it!

Anyone else having trouble opening the devlog google doc? The first page loads a preview but nothing else appears. Says "couldn't preview file - there was a problem loading more pages."

Same issue - @maudlin27 maybe the file is too big? 🙂

A work of art is never finished, merely abandoned

@sioloc I've split it out into several documents to reduce the size slightly, let me know if you still have issues accessing.

Thank you so much for your work. I'm one of those players who really loves playing against AIs, but I hate AI that is too easy or cheats. It seems to me like you've made the best vanilla (well, vanilla-ish since it's on FaF) AI. It's currently kicking my ass. I'd really love it if you would continue working on it to make it even tougher, and also resistant to all sorts of cheesy tactics used by humans to beat it quickly. I also really like how it's not specialized for a single type of terrain and it can play navy as well. Anyway, just wanted to voice my appreciation.

Just came here to say thanks @maudlin27, this is really appreciated. Uveso was kinda challenging when using x1.5 multipliers, M27 is even better without even any multiplier. Can't wait for M28.

Latest changes (v67 summary)
No significant changes in this update, just a number of small tweaks and fixes.

13 bugfixes, including:

  • Certain SACUs being considered to have 0 threat
  • Improved build order on some maps that resulted in a power stall due to power and hydrocarbons being built at the same time

25 misc changes, including:

  • Mobile shield and stealth sharing (so cybrans can share the joy when they have non-cybran teammates)
  • Novax targeting adjustments to prioritise lower health instead of higher health units of the same type
  • Slight increase in navy aggressiveness (including a workaround for humans who would constantly dodge aeon destroyer shots with frigates when massively outnumbered)
  • Improved nomads compatibility by building T2 support factories and getting the gun upgrade
  • Increased likelihood of UEF and Seraphim building game-enders in team-game maps


  • Relent0r – highlighting an issue with M27’s build order on theta passage, and with M27’s ACU getting stuck on Air Wars
  • Radde – Numerous replays
  • SniperbotMeta (now Flordia Man) – Feedback on issues M27 has with nomads
  • Jip – Highlighting how using ForkedThreat on a function that returns a value will cause a ‘Yield()’ error message

V68 summary of changes:
Various small improvements to tml and tmd logic:

  • tmd can now be built on plateaus
  • predictive logic added to estimate if a tml shot will hit the cliff to help with target prioritisation
  • tml are less likely to be paused when stalling

14 other misc changes, including making unupgraded acu scared of all pd and improving plateau expansion speed

16 bugfixes, including:

  • t1 pd shouldnt be ignored by the threat response logic
  • pre-emptive fix for upcoming faf develop changes to veterancy
  • fixed various niche scenarios causing errors and reduced some of the error messages sent to the log


  • Fearghal – Bug where M27 ignored civilian T1 PD
  • Relent0r – highlighting a dangerous upgrade decision by M27
  • Sprouto - sharing thoughts on TML missile trajectory that led me to trying to come up with the predictive missile logic

v69 Summary of changes
Mini update with 7 bugfixes and 12 misc changes, including:

  • Fixed an issue that could cause a major slowdown when M27 was power stalling late game
  • Better plateau selection in team games (previously sometimes two M27 would each go for the plateau furthest from them but closest to the other M27)
  • Improved SMD/anti-SML logic to handle large enemy AiX modifiers, large enemy nuke numbers, and attempts to edge-nuke M27's ACU
  • Adjustments to naval kiting logic so they take longer to turn around (and therefore less likely to abort a firing sequence after a single shot)


  • Fearghal - Highlighting a significant slowdown in an M27 game that led me to discovering the flaw in M27’s power stall logic.
  • Thacon - Replay highlighting poor plateau selection by M27 on the same team

Hi @maudlin27, I've just been reading your development notes and really appreciate how thoroughly you've documented everything. As a programmer myself it's really interesting to see what you learned along the journey 🙂 I'm also enjoying your M28 blog - looking forward to seeing how that goes!

BTW, I'm still having issues opening the devlog ( - maybe that's also grown too big for google drive to show?