AI Development Guide and M27AI v74 Devlog

@maudlin27 - I like the AI and have had some good games against it. I enjoy the blog too. I did notice a small bug on Setons where it air-dropped engineers on the plateau but never built on the mass extractors. The engineers just sat there for most of the game with untouched mass extractors right beside them. m27bug.jpg

@tyne141 Thanks, have you got a replay ID, as I've not been able to reproduce on either the FAF or non-FAF setons?

Also was this the latest version (as v39 fixed a couple of bugs that in some scenarios would cause Plateau engineers to not build mexes)

@maudlin27 It was a modded game. It would probably be a pain to replay https://replay.faforever.com/17253648

I saw there was an update since I last updated so I gave that a shot and got no where. On start:

warning: false\000M27ERROR Count=1: GameTime 4: sBlueprintToBuild is nil, could happen e.g. if try and get sparky to build sxomething it cant - refer to log for more details
warning: stack traceback:
warning:         [C]: in function `assert'
warning:         [C]: in function `pcall'
warning:         ...nder forged alliance\mods\m27ai\lua\m27utilities.lua(74): in function `ErrorHandler'
warning:         ...d alliance\mods\m27ai\lua\ai\m27engineeroverseer.lua(3146): in function `BuildStructureAtLocation'
warning:         ...er forged alliance\mods\m27ai\lua\ai\m27overseer.lua(7173): in function <...er forged alliance\mods\m27ai\lua\ai\m27overseer.lua:7154>
info: BuildStructureAtLocation: Had category to build. oEngineer=ual00011; UC=1; All blueprints that satisfy the category={ table: 27460820 
info:   "drlk005",
info:   "uab0101",
info:   "uab0201",
info:   "uab0301",
info:   "ueb0101",
info:   "ueb0201",
info:   "ueb0301",
info:   "urb0101",
info:   "urb0201",
info:   "urb0301",
info:   "xrl0002",
info:   "xrl0003",
info:   "xrl0004",
info:   "xrl0005",
info:   "xsb0101",
info:   "xsb0201",
info:   "xsb0301",
info:   "zab9501",
info:   "zab9601",
info:   "zeb9501",
info:   "zeb9601",
info:   "zrb9501",
info:   "zrb9601",
info:   "zsb9501",
info:   "zsb9601"
info: }

(Ditto Mods)
https://replay.faforever.com/17253862

@splitice Thanks for the replays,

Re the second replay, the issue is compatibility with one of your mods. M27 will currently only apply engineer logic to land engineers, but after doing some debugging it looks like the mod combination you're using results in the normal engineer blueprint (e.g. uel0105 for UEF T1 engineer) being modified to contain the air category instead, which I'm presuming is the Flying Engineers mod. I'll add in a fix in the next version so M27 will try and build stuff/use the engineers where it detects this mod or can't identify any T1 land engineers that are buildable, but it's likely there will still be some unintended sideeffects/interactions.

Edit: Checking the first replay it's the same issue as the second (with the flying engineer mod causing issues) - this will be fixed when v40 releases

@maudlin27 said in AI Development Guide and M27AI v39 Devlog:

nks, have you got a replay ID, as I've not been able to reproduce on either the FAF or non-FAF setons?
Also was this the latest version (as v39 fixed a couple of bugs that in some scenarios would cause Plateau engineers to not build mexes)

It wasn't on v39; I think it was on v37 or v38 as I played the game about 1 day before v39 released. The replay URL is: https://replay.faforever.com/17259833

It's a bit of a weird match as I was just testing M27 against Sorian out of curiosity so I was only human player in the match. I haven't seen the bug happen when I've used M27 with humans but I haven't played on many maps with plateaus with humans yet.

@tyne141 The issue might've been fixed in the last update but to be safe I've added some further logic to the (WIP) v40 to make sure that specific scenario shouldnt happen (the issue being the engineers were stuck assisting the land factory, and never had their orders reassessed once the land factory had finished building all the units wanted for the plateau)

Thanks for the quick feedback; it's really great to watch the AI develop as you add to it. I'll try running a similar setup again on v40.

One other thing that a friend and I noticed when we played 2 humans VS. 2 M27s on V39 last night was that one time a commander killed itself by standing in the channel on High Noon and getting hit by 3 x T1 torpedo launchers. The commander seemed to retreat most of the time when it was damaged a certain amount but it didn't seem to detect it this time. The other thing was that the AI didn't seem to respond very quickly to T2 UEF cruisers attacking base buildings; it was still very challenging to win but we managed in the end partly through weakening their economy through cruiser missiles. I think we played about 3 games in a row and eventually won the last game. I can find the links for the replays if they're useful; I assume it was on V39 as I think we updated last night before playing. It's still really challenging as the AI was very quick to hit us with nukes and/or experimentals if we let it grow for too long.

@tyne141 Yes replays of games between M27 and humans are always useful even if there’s no obvious issue/error.

The t1 torp launcher/acu point sounds like a bug (Edit: Reviewing the code for this there was a flaw that likely explains what you've described which will be fixed in v40) while the vulnerability to cruisers is more of a weakness with its current logic that I need to try and improve at some point (so a replay that highlights this would be helpful).

@maudlin27 thanks very much.

I thought it might be mod compatibility but I was thinking Auto Reclaim. I look forward to seeing what the next release can do.

@maudlin27 - here are the replays:

From memory, we lost the first two games but it was in the second game that one of the commanders died early because it didn't move away from the torpedoes; the remaining team still beat us convincingly by teching up and hitting us with experimentals. I think we won in the third game mainly through long range naval.

For context, we haven't been playing too long but we're easily beating the standard AIs and Sorian etc; we don't really play against other humans much yet so we're not exactly great players but it's offered us more challenge than Sorian or LOUD which are the other AIs we've played against so far.

@tyne141 Thanks, the replays highlighted a number of flaws/tweaks to make so hopefully it can give a bit more of a challenge in the next release.

@maudlin27 - awesome, it's great to be playing against an AI as it is evolving so we know that we can't just learn how it behaves once and remember how to beat it.

Out of interest, is the intention to definitely add navy/sea eventually if there is time to do it well? Or is it potentially easier to make an AI difficult to beat if it concentrates its resources on land and air? I notice that some of the AIs that do build navy don't defend them too well so it is often easy to knock out naval factories in which case it is a massive waste of mass for the AI but I assume that an AI that can strategically use certain naval units could be quite tough to beat.

@tyne141 I've still not decided whether to get navy, and if so to what extent to do it - as you mention it's very easy to waste a lot of mass on navy if it's not implemented well, and it's further compounded by me not really knowing how to play navy well as a player.

V40 Update – Deceiver and naval defence

  • New unit unlocked: The deceiver
  • Various tweaks aimed at improving M27’s response to a nearby naval threat slightly
  • Added basic support for the flying engineers mod
  • 14 other misc changes and 11 bugfixes

Acknowledgements

  • tyne141 – Replays highlighting issues with torpedo defences and cruisers
  • splitice – Replay indicating incompatibility with flying engineers mod

@maudlin27 said in AI Development Guide and M27AI v40 Devlog:

Various tweaks aimed at improving M27’s response to a nearby naval threat slightly

Thanks for the acknowledgement; here's a couple more replays if you want:

It was 2 games of 2 humans VS 2 M27s on Eye of the Storm. We lost the first one but won the second. There didn't seem to be any major bugs but in the second match, the bottom right AI sent its commander diagonally across the whole map underwater which meant that it was completely vulnerable to torpedoes. So it almost got taken out by a lone T1 submarine. We lost the first match in a big part due to the M27 firebases being quite effective and me not defending against the T2 artillery quickly enough; however, in the second match it didn't really seem to build the firebases as effectively at the top or bottom so we just skirmished across gradually.

Played a heavily modded game (primarily fast build, increased storage, increased nuke defence build rate, defence expanded). 1x AIX vs 1x human.

@maudlin27 well done... took me over 2 hours (Uveso with the same settings would be sub 1hr typically).

Got forced to turtle up to the middle a bit the AI was very overwhelming with a constant stream of high tier units controlling the center.

I'm betting it would have had enough resources to build more experimentals however it didnt. Might have been able to win if it did. One area AIs can typically offer more challenge to human players (if resources permit) is by building experimentals as that requires extensive micro management as a human.

It never tried for a nuke win. T4 Arty was disabled in this match so there was no Arty win possible.

I won via area supression followed by brute force nuke win.

  1. Area for improvement.

Don't park within range of guns

  1. Area for improvement

In the above screenshot that was a fleet of T1 and T3 engineers primarily. Seems kind of useless?

Tried to invade with that engineer army multiple times. Cannon fodder strategy?

Overall - good game. Played well. Slowest point with large armies clashing -2, typically +2.

Also flying engineer strategy:

  • Fly in over land defences and take them 🙂

Might have been a good strategy for that engineer army.

@tyne141 Thanks for the replays, looking into further there's a bug with my logic on 'chokepoint' games (such as 2v2 eye of the storm) - will be fixed in v41 (I'm just working through a few adjustments before I release).

@splitice I'll have a look after the current release to see if there are any easy adjustments to help fix, but some of my logic's range is hardcoded which may cause issues if the mod is introducing very long range units. I'll double-check how it handles things when T4 arti is disabled though, as it's quite possible it is trying to build it, and when it fails due to the unit restriction it stops building any experimental, leading to poor use of resources. I'm just going through pre-release checks on my current release so it won't be until v42 for any changes re this though.

@maudlin27 Iterate the blueprints on start for unit ranges perhaps? Thats how unit stats are normally changed so it makes sense to do the same on first tick.

It didnt build zero experimentals (I saw a few galactic colossuses before taking the center) but they were limited. Towards the end of the game I would have expected to see waves of them.

v41 Update - Hives and Shield Disruptor

  • Added new unit – Shield disruptor
  • Added new unit – Hives
  • Fixed various bugs/assumptions that meant M27 wouldn’t work with the survival map Final rush pro support (in preparation for an AI monthly tourney on this map)
  • Fixed bug on some chokepoint maps (such as 2v2 Eye of the storm) with the chokepoint assignment
  • 10 Other bug fixes
  • 53 Misc changes, including various tweaks to late-game logic in high mass scenarios to try and build more land factories sooner, assist SML and SMD with fewer engineers if mass is overflowing, build more power, and adjustments to T3 arti targeting logic when the enemy has no T3 arti of their own. Also including various tweaks to the early game such as initial build order tweaks and slightly better use of early raiders so theyre less likely to die.

Acknowledgements:

  • Tyne141 – Replays highlighting strange choice of destination for M27’s ACU when turtling
  • Zlo – suggesting I ctrl-K obsolete radar rather than reclaiming it
  • Relent0r –Querying whether M27 chooses not to upgrade mexes in range of enemy TML (prompting a tweak to incorporate such logic).
  • Ice-IX – Bug where disbanded platoons would have their displayed name change even if the config settings said to not do this.

Benchmarking
As it's roughly 1 year since I first started working on M27, I thought I'd benchmark how well it was performing against several of the other AI (DilliDalli and RNG, as they're the 2 AI that during testing are most likely to beat M27), in part as one of my long term goals had been to create an AI capable of beating all other AI on the <700 rank map pool a majority of the time.

While M27 just managed to reach this goal (after numerous small tweaks to its early-game logic), it was very close on several maps so this will be highly dependent on the map pool chosen. The devlog has more details on the results, but in summary (with 4 faction mirror matchups being played against each AI, and then another 4 in the case of a tie in results):

Maps with 100% win rate:

  • Theta passage
  • Auburn Canyon

Maps with a clear >50% win rate:

  • Adaptive Hardshield Oasis (3 win 0 loss vs RNG, 4 win vs DilliDalli)
  • Regor VI Highlands (4 win vs DilliDalli, 3 win 1 loss vs RNG)

Close fought maps:

  • Loki - FAF version (3 win 1 loss vs DilliDalli, 2 win 2 loss vs RNG followed by 4 win 0 loss)
  • Forbidden Pass – FAF version (7 win 1 loss vs RNG, 13 win 9 loss vs DilliDalli)
  • Point of reach (4 win vs RNG, 2 win 2 loss vs DilliDalli followed by 4 win 0 loss)

In terms of the other map pool maps, Serenity Desert Small – FAF version currently has a bug that prevents RNG and DilliDalli working on it so the results aren't included