M28AI Devlog (v102)

@maudlin27 A quick question. I tried playing 20x20km Voodoo castle with 5x M28's with all units enabled. For some reason the game was pausing every few seconds from like minute 2 onwards, F11 revealed i am behind in data. With air/nuke/t3 arty disabled the game will play normaly, though reduced sim speed from min 30 onwards (expected). Do you think the game should be able to handle this settings normaly or is the map to big ?

I kept playing 1 such game and after like 15 minutes, it crashes, with error message "warning: Error running lua script: out of memory". I attached the .log for you.

Thanks for your work, me and my friend play with M28 all the time and have great fun !


@goblinsly2 Normally I would expect M28 to handle a 20km map with 5 AIs (absent mods), but checking the map I suspect the reason is the large number of cliffs - whenever an air unit flies over them M28 tries to figure out the closest land area to it, which results in a significant strain where there aren't any nearby (both requiring more CPU resources, and more memory usage).

The crash was ultimately due to exceeding the memory, while the stuttering early on was primarily caused by its logic for calculating the zones near a particular air unit.

I'm doubtful I'll be able to make a significant improvement to how M28 handles that map but will have a think if there's anything. Other suggestions which I would expect to help would include:

  • Reducing the factions used (which should reduce memory usage)
  • Using unit restrictions to ban all air units (which should improve both CPU performance and memory usage)
  • Playing an edited version of the map that cuts out most of the unpathable cliffs on either side (this would only work for personal use though as you wouldn't be able to upload such a map to the vault without permission of the original author)
  • Disabling other SIM mods (you had RNG and M27 also enabled - there's the possibility this could increase the memory or cpu usage)

v80 Update
Some (but not all) of the planned changes from the Rainbow Cup finals. Since a number of these changes affect core parts of the land and air unit functionality there's a greater risk of unintended consequences or bugs.

  • 7 changes from the final game (on huge adaptive wonder), including having fatboys move instead of attack-move when faced with negligible enemy threats (so they cant be held up by land scouts on repeat), and various adjustments to asf targeting logic so they'll commit to nearby targets, prioritise closer targets, and include air units betwen their main target and the current rally position.
  • 3 more changes from an earlier RC game on Norro that I'd missed from a first pass, including fixing a bug that would cause the ACU to not consider the proper units when deciding whether to attack or retreat, and some refinements to land scouts so they are less likely to retreat when friendly units are near.
  • Reworked how land combat units are managed to try and stop M28's entire army chasing after a lone enemy scout/low threat unit. Where M28 significantly outnumbers the enemy it should only send some of its army to deal with the enemy, and the remainder should search for a larger enemy force to attack.
  • 3 Optimisations for maps with lots of cliffs so that M28's land based logic gets run less frequently for small plateaus; the plateaus get ignored for most of the air based logic; and are also ignored when determining what zones are between the start and end position.


  • Fearghal - for funding and organising the rainbow cup tournament (which provided various valuable replays and ideas for improvements)
  • TheWheelie, Tryth, and likely others (apologies if I've not mentioned you here) - various discussions in the rainbow cup discord thread following the end of the tournament with suggestions on AI improvements (some of which are planned for an upcoming version)
  • Saver (and Relent0r) - Error message relating to part of M28's land logic that would sometimes occur.
  • goblinsly2 - Replay highlighting performance issues on the map Voodoo Castle (as a result of the large amounts of unpathable locations).

@maudlin27 I just played a game on Voodoo Castle with 3x M28's and 2x M27's, accidently not setting any restrictions. Im glad to report the game went through without a single problem, staying at 0 sim speed throughout. I didn't see a lot of air units on my team and was amazed that M28 donated some of them to me. Whether accidental or meant to reduce lag, i loved it, felt like a human player, but spoke english. So far works great.

@goblinsly2 Good to hear, thanks for letting me know.
I'd still suggest trying to only do M28 rather than a mix of M28 and M27 given the memory issues you were having before (i.e. while the v80 changes should have helped to some extent, I only confirmed the cpu performance impact on that map and I didn't measure how much of a beneficial impact they had on memory usage). However, following v80 it's hopefully no longer necessary to apply unit restrictions on that map.

Giving air units is an intented feature for M28 - if it sees you as the more dominant air player compared to itself then it's meant to gift over some of its asfs.

@maudlin27 I have a problem that happened to me before on this map. I started a game with only M28 and Uveso selected, i used a saved preset for unit restrictions. When the game starts i get an alert that M27 can be disabled since its not detected. And the M28's dont start building (neither does the game stop when they usualy start collecting map data). Is this a problem on my part ? Attached 2 logs when this happened.

Second thing, you mentioned its normal that M28's donate units. But i dont have the same capability. I cant donate units to AI's, i cant convert them and i cant share resources with them. Which is a bummer if i build paragon for instance. Can i change those settings somehow ?game_22089600.log game_22089573.log

@goblinsly2 There's a bug with how the game lobby handles presets that makes it incompatible with AI so that's likely the cause of the first issue - where I've seen it before it appears to have the selected AI (e.g. M28) in the game, but it's using the default AI. My suggestion is to start a fresh lobby/game and not use pre-sets to see if it works.

The second issue would need a change to the game I expect for it to work via the normal interface, if it's even possible. However, one workaround is to use 4z0t's scoreboard UI mod (along with the associated UI tools mod), then if you select the units you want to gift, then do Ctrl+L Click on the faction icon on the scoreboard for your teammate it should gift the units to them.

@maudlin27 game_22094987.zip

I tried and it worked. Today i had a problem when launching nukes, game locked, infinite loop or so the log tells. The other day i didnt have issues with similar settings. This map is wierd i guess. Had to zip the file cause its over 6mb

@goblinsly2 Thanks, it’s a known issue where M28 has 2 nukes that try to fire at the exact same time, I’m hoping to release a hotfix tomorrow that fixes it

v81 Update
Small update as I wanted to rush the nuke crash fix.

  • Fixed 2 bugs that combined meant if M28 had 2 SMLs fire at the exact same time it would crash the game
    14 other tweaks and fixes, including:
  • having M28 try and get more T3 land spam before its first experimental
  • getting more land factories in some cases particularly in a 1v1 on a 10km map (previously it'd only do this if the 10km map didnt have many mexes)
  • making ACUs more likely to dodge lobo arti shots
  • Reassignment of engineers constructing M28's late game shield and arti template if stalling energy


  • Fearghal (and goblinsly2) - Replay containing a crash (caused by M28 firing 2 nukes at once)
  • Radde - various replays against high AiX modifiers, including beating a 1.5 AiX on a 'large' 10km land map


  • Sladow trophy - Retained by Radde by beating 1.5 AiX M28 (v80) on Xander Adaptive

(no change to the Radde trophy which was won by Radde, Mhad and GhillieWolf against v59 M28).

@maudlin27 Tnx, i will test the nuke fix today hopefuly and let you know.

Yesterday i had a long game again on that vodoo map and made some observations, but since this map is so specific, i don't know if it's even worth changing AI because of it, but i will write it down anyway.

First thing is, neither M27, M28 or Uveso made navy on this map. But it did make sonar. Water is far from bases, but it offers critical advantage. First, with navy superiority u can destroy like 8 mexes near the shore and completely clean the place of enemy units, then spam long range missile ships or subs and u can reach most of the bases. Second, you can spam experimentals under water and then rush in with them while enemy has most units elsewhere.

another thing i noticed on this map but not sure if it can be solved or if it's even a problem anywhere else. This map has long path on left and right side. At the start, units flow ok through them. But once we reach T3 and there are tons of percies/fatboys or similar units, the way gets blocked. Yesterday both sides were blocked for probably 1 hour.

Bases were pretty packed also, it seemed with way more T3 engineers than could be supported by economy. I noticed that while M27 on a big map had a tendency to eco beyond T3 mass extractor with tons of fabricators and then spamming RAS commanders, M28 is not to keen on doing that. On this map that is easily defendable, M28 will be left behind, unless there is an aeon in the team.

Thank you for your work, its great fun playing M27 or M28

game_22109326.log Just finished an awesome game and am happy to report that the nuke crash is gone. I still dont know how enemy cybran could have built so many megaliths that fast, doubt their team built paragon that fast. It was super fun nuke heavy game, no air/t3 arty/experimental arty and satelite. A couple of unexpected things happened. All AI's stopped using nukes after about half the game, even though there was plenty of traffic on sides where nukes were flying before. I thought maybe the nuke code has stopped working, but then right at the end of the game, my ally sent a nuke into a base of 20 anti nukes and killed 2 coms with it, amazing precision. What was wierd also that all seraphim and cybran AI's completely stopped making experimentals, so it was just me as cybran, my ally uef and enemy aeon still making them. Surprised me since just at the start enemy cybran made like 10-15 mega's. Anyway, great job on AI, super fun game.

ps: i see what you did there with mobile arty and cloaked com's 😉

@goblinsly2 Thanks, it's possible that SMD coverage meant the AI didn't think firing a nuke would be worthwhile, but there are some unexpected errors in the log relating to nukes so I'll make a note to have a look at some point to see if they can be fixed.

v82 Update
15 adjustments mostly based on replays from Radde (beating 1.4 and 1.5 AiX M28 on Xander Adaptive), including:

  • Better use of MMLs in larger numbers (so they no longer all focus down 1 target at a time), and slight increase in aggression for T3 mobile arti1
  • Adjustments to pausing of units in power stalls and factory build decisions to reduce the likelihood M28 gets stuck overbuilding engineers early on (due to overflowing mass as a result of stalling power)
  • Gunships should be less suicidal vs enemy air when defending locations near to M28's starting base


  • Radde - Another 3 replays vs M28 on Xander Adaptive
  • Cthulhu - log with blacktops incompatibility message
  • goblinsly2 - log with nuke launcher error message


  • Sladow trophy - Retained by Radde by beating 1.5 AiX M28 (v81) on Xander Adaptive

(no change to the Radde trophy which was won by Radde, Mhad and GhillieWolf against v59 M28).

Hi, came here first to say THANK YOU to @maudlin27 for his great work in developing another AI. I almost exclusively play against an AI with a friend, and M28 has made this much, much more interesting again!

Secondly, I noticed that, e.g., on map TeamdefensebyKC, M28 is, after some period of time, just sitting there, doing nothing at all. I just setup a game with just me and a few AI to test just that. If it should be of interest, I do have a game log and a replay saved here.

@hammi Thanks, glad to hear you’re enjoying it! Do you have the replay ID number of the game you’re referring to, roughly when it happened, and a bit more detail on what you mean by it doing nothing (eg acu stood still and it never built anything?)

@maudlin27 Thanks for being willing to look into this. This is the replay: https://replay.faforever.com/22129264

As you can see, the AI plays ok until about an hour into a game. It then completes a Quantum Arch, which apparently stalls its economy in an unforeseen way (can't see any enemy influence causing this). It then appears to build energy gens to compensate for that. Even after economy has recovered, all it appears to do it wait for few units to exit the arch. Further energy gens have been planned, but are not being built.

After 25 mins, I ran out of patience. 😁

@hammi Unfortunately the replay desyncs for me part way through; In the desynced version it didn't seem to have issues with building things, and I can't see an obvious error in the log you provided. It's possible it was using up all its mass on building things of little consequence hence why it didn't seem to be doing anything.

v83 Update

This update is essentially lots of minor tweaks based on replays from Radde. 30 changes made, none of which are expected to be that significant, including:

  • Increased the focus on ACU snipes when an ACU is considered vulnerable
  • Further adjustments to fatboy and megalith to reduce their tendency to attack-move when the enemy has a large nearby threat but a small in-range threat
  • Greater prioritisation of very high reclaim amounts
  • ACUs should be less likely to stand in their base waiting for an approaching experimental to kill them
  • Expanded ACU upgrade choices slightly so shield/nano should be got instead of RAS if the ACU is low health (and also obtained late-game where it wouldn't replace RAS)
  • Fixed some bugs with tracking overcharge shots (which led to ACUs not dodging t1 arti shots as much); working out how many t3 arti/gameenders are already under construction (which led to t3 arti being built at the same time as a mavor); TMD being massively overbuilt


  • Radde – Numerous replays which formed the basis of almost all the changes in this release (and I’ve only been through half the replays so far).

I just came from 2 incredibly strange games, not sure what happened. It's the vodoo map with air enabled, t4 nuke/T3T4Arty/Satelite disabled. I played like 10 straight games with this settings and won them all. Now lost 2 in a row. But the reason is really simple - AI's on my team play differently than AI's on opposite sides. My AI's make practicaly no ASFs, while the enemy makes 100's and 100's of them. Now, crappy as i play, we would be ok if we each made 1/3 of the airforce. But basicaly we are 1 hour into the game, getting bombarded with 4 or 5 experimental bombers and i am the only one making ASFs, while 1 player is making fatboy and the other chicken. I attached a replay link and log, pardon my language in the replay.