M28AI Devlog (v158)
-
Awesome! Very cool if we're going to have two specialized M27/28 AIs, one focused on 1v1 and one on team battles. I assume since this is going to be team focused, it will also focus on larger maps than the first M27 AI?
-
@saintsaturday It'll probably have a similar focus of 5km-20km maps, but my hope is it ends up running faster meaning it won't slow down the game as much on the larger maps (and so can support them a bit better). I'm also hoping it will end up playing slightly better on 20km maps (or at least have the potential to) as some of the downsides of M27's approach to managing threats to its base become more apparent on larger maps, particularly where it ends up receiving a teammate's base on full share.
FAF balance isn't really setup for 40km+ sized maps though so I can't see myself doing much testing on these (since the optimal strategy is usually to get a game-ender which M27 should already try and do).
-
Brief progress update:
- Added ecoing logic, covering upgrading mexes and land factories to T3, building T2 and T3 PGens, and mass storage
- Added reclaim logic for engineers
- Added land scout logic, to provide a basic level of intel
- Optimised engineer logic that managed to achieve negative game speeds on maps like point of reach despite there being no land, air or naval logic yet
-
@maudlin27 could you point us to the commit that optimized the logic? I'd love to see what happened
-
@jip See below for a link to the commit:
https://github.com/maudlin27/M28AI/commit/82fbcfff116a59da09d39b653a1fb8b0d93bd4dc#diff-aacec693b8e05ca3fb26c9a47a43372cb938685e86dbf5604c3a50b1f4001d77My Devlog talks through the issue (section 2.11) but in short I've divided the map into 'land zones' (basically areas around mexes) and my engineer logic had a section for each zone where it would look for other zones that needed engineers and send any spare engineers they had to the other zones.
To make sure they didnt suicide by sending engineers along a path that would e.g. take them through an enemy base, they would check before sending the engineer that all of the land zones they would travel through appeared safe by getting the path to get to that zone, and then checking a pre-recorded flag for if that zone had enemies in it.
The performance improvement was to calculate at the start of the game the paths that would be taken from each land zone to each other land zone (rather than calculating on the fly), along with a slight limitation on the range of the logic, which resulted in a more than 99% decrease in the time taken.
-
Progress update:
- M28 can now manage tanks, skirmishers, and indirect fire units
- Expanded engineer logic to cover radar construction and tracking queued buildings
- MAA will be constructed and utilised
- Mobile shield logic incorporated
The M28 Devlog has been updated with more detail on the various changes.
As a reference point, on forbidden pass M28 has a c.75% win rate against DilliDalli, a 50% win rate against RNG, and a 0% win rate against M27, so its performance is slightly below that of v41 M27 on that map (although it's managing to do it without using PD, air, or its ACU, all three of which M27 typically needs to beat DilliDalli).
-
Can't wait for new DG meta where you give 6 players worth of units and eco to each M28 and see who wins
-
Progress update: Added the following:
- ACU combat logic
- Mobile stealth
- Enemy firebase avoidance (although still needs some work)
- TMD
I'll probably pause work on M28 for a bit to tackle a backlog of minor but time consuming to fix bugs on M27.
If anyone had wanted to try it out pre-release, it should be in a playable state on land maps and can be played by downloading from Git and coyping the M28AI folder into the FAF mods folder:
https://github.com/maudlin27/M28AIIt currently can beat M27 on theta passage but is outclassed on every other map I've tried, and performs marginally better than DilliDalli and RNG on the maps tried (a small selection of 5km and 10km land focused maps).
-
-
-
-
-
-
-
Progress update:
Most of my work (when I wasn't updating M27 for the rainbow cup) has been focused on having M28 function on maps with water - for now, without building a single naval or air unit. This took far longer than I expected despite using a very similar approach to how M28 handles land units, and I expect there will still be a number of issues to work through once I have M28 able to build naval units (although most of the hard work should be done now).- Shields should be built to defend against enemy T3 arti/novax
- SAMs should be built across the map if lacking in air control (which M28 will since it doesnt built any air units!)
- Added logic to consider locations on an island by island basis, so engineers can move from one island to another, and establish a beachhead on an island to try and take control of it
- Put in place framework for 'water zones', which divide the map up into areas similar to what M28 does for land zones, so that naval forces can be handled on a localised manner. These zones are much larger than land zones in size, and for now use simplistic pathing which I expect I'll need to revisit at some point if I can speed up the logic for this.
- Combat units in water are now managed, and will consider fighting other water based threats or to move onshore (if amphibious) to fight for an island
- Engineers can now reclaim and build underwater mexes
I'm also going to start using branches for future updates (so if anyone's running the AI off github, the main release version is likely to be more stable as sometimes when I'm in the middle of a major update Ill post the changes to backup them, which could lead to the logic breaking if trying out the latest branch)
-
Progress update:
Introduced most aspects of air based logic (main exception are bombers):- Torpedo bombers
- Air scouting
- Gunships
- Asf/inties
- Transports (and engi drops)
Have merged the air logic branch as it should be relatively stable. Asf/intie logic will need some refinement as M28 has a tendency to suicide them, but other aspects such as the gunship logic from initial results looks like it is performing slightly better than M27's version.
-
-
-
-
Progress update: The end of the beginning? or the beginning of the end?
A lot has happened with M28 in just 2 weeks, such that I'm hopeful that it's release date could be in a matter of weeks rather than months. To summarise what's been implemented:
- Naval logic, including building and upgrading naval factories, building naval units, and using naval units
- Novax
- Nukes
- TML
- T2 PD (although in a very limited/niche way comapred to M27)
- Ahwassa
- T3 arti
- Various small changes to improve its performance slightly (e.g. less likely to overflow mass, doing better on maps where it can only reach the enemy with air, logic for engineer order reprioritisation)
M28 now has all the core features that I'd set out to implement ahead of the release (some original points such as T3 bombers were pushed to be post-release but others like T3 arti and T2 PD that were planned for post-release have already been implemented). The main areas it needs work on are compatibility (making sure various niche scenarios work), and a new set of 'competitiveness' related goals I recently added - in short, making sure that while it may not be as good as M27 it should perform similar or better to the other custom AI when released.
The most exciting point for me personally though is the performance gains M28 is still suggesting it will provide compared with M27. When I'd previously ran it on the scenario I used for M27 for benchmarking (4v4 UEF on Africa) it was significantly faster, but that was before air and naval logic were added, and there was always the danger that I could spend half a year building an AI hoping it would run faster, only to find out it was slower. Now though it has almost all core features, and is still much faster (more than double the speed).
- For example, taking M27's 'benchmark' map of a 4v4 UEF mirror on Africa, M27 v67 took 167s to run the first 10m, and encountered stuttering for 20.8 seconds cumulatively.
- By contrast, M28 took 67s, and the cumulative time of freezes was just 0.4 seconds. The only main caveat to this is it freezes the game for a while (probably at least 1 minute) at the start of the game which is much longer than M27, but overall it should still be faster for games running 10+ minutes even after factoring this into account.
- Although not tested (as it's hard to produce an easily comparable scenario), I'm also confident that logic for T3 arti should be far lighter on the CPU than M27's approach which should help late game (as I suspect this was a likely culprit of some of the slowdown, along with M27's preference for swarms of T1 bombers).
-
That is great progress
-
M28AI's release day has arrived!
The main changes made from before were focused on compatibilty, (cpu) optimisation, and increasing its difficulty.
Compatibility
Tested M28AI with the following mods and map settings (usually this just consisted of a single game, so please let me know if you come across any issues):- Maps with water starts (including all-water maps such as Dreadnought Chasm)
- Survival maps
- AI Wave survival mod
- Flying engineers mod
- Norush game setting
- Low unit caps
- Crazy rush
- Nomads
- BlackOps
- BrewLAN
- Max AiX modifier (IIRC 5.9)
Optimisation
Big thanks to @Jip who helped me achieve a significant reduction in the time taken by M28AI to analyse the map at the start of the game. Previously M28AI was taking more than 2 minutes on 10km maps such as polar depression, with one of the functions being run taking c.102 seconds. With Jip's help this function's time was reduced to roughly 0.2 seconds, with M28AI completing its analysis in most cases in 30s or less (slower CPUs will take longer). The devlog contains more information and profiling for this.This also allowed me to make use of more accurate water zone generation (without increasing the analysis time).
Jip also helpfully provided code to allow M28AI to get the navmesh label (broadly, whether a particular part of the map is pathable by particular units) for a particular point on the map (which was needed for the optimised code mentioned above to work properly).
Competitveness
Various tweaks and improvements were made to make M28AI provide a harder challenge. As part of this I made sure that M28 was capable of beating RNGAI and/or DilliDalli AI on a number of maps (including those maps I'm aware of where they're capable of beating M27AI some of the time).Rather than try and achieve >50% win rate on all these maps, I instead just aimed for a single win, and did the AI version of 'save scumming' with replays until M28AI either won the replay, or creating a new game on the map resulted in it winning. Outside of Astro Crater (where M28AI is able to beat M27AI a majority of the time) I didn't test M28AI against M27AI. This is because I realised early in the development of M28AI it was too demotivating to watch it get crushed by M27AI (wheras against RNGAI and DilliDalli AI even if it loses often it's a close fought game, providing me with motivation to try and improve M28AI as opposed to giving up).
As a rough count this process involved 109 tweaks and improvements to M28AI (examples of more impactful changes within this include T2 artillery construction, destroying obsolete radar, and basic logic for building and managing bombers).
Since I've played a grand total of 1 game against M28AI (just to make sure M28 didnt take control of my units when it was my ally against 2 enemy M28AI), I expect it will need a lot more changes to improve its performance against players and become 'cheese resistant'. Almost all games were 1v1s (since they're faster to test) so although the code was all written with the aim of working in team game scenarios, I expect these aspects of it logic will be a bit rougher around the edges.
Please let me know if you have any feedback, suggestions, or encounter bugs.
-
After my record for the longest version (in development and code length) ever comes my record for the shortest version ever (a 1 line change)! Big thanks to Relent0r who mentioned M28 wasn't building any tanks, which was due to a bug that arose when one of the common debug options I use (showing unit names) was disabled.
-
v3 - Starting a new campaign
- Added preliminary support for campaign maps - currently I've only tested on the first FAF mission (Black Day), and I expect on many maps it won't work properly (due to one of the bugs identified below potentially completely breaking M28 I decided to release earlier than planned as a part-hotfix update). My aim will be to improve M28's performance over time (e.g. currently 1.5 AiX M28 struggles on easy on black day if the human player does nothing). As part of this, M28 allows an AiX on campaign maps of up to 10.0 AiX for the M28 teammate, and will take its share of initial units at the start of a game (since it's not possible to gift units to an AI ally in the campaign)
Note - if playing with M28 as a teammate, a higher unit cap is recommended. - Improved the basic bomber management logic (idle bombers should return to a safe location, large numbers of bombers should search further away for enemies)
- Improved build order on certain maps (e.g. on maps where the only mex adjacent factory build locations are blocked by reclaim, M28 should now try and just build the factory in a 'clear' area so it starts construction sooner)
Fixed a few bugs, including:
- M28 potentially not working on some maps with water
- PD being way too far away from the base (more an issue on 5km maps)
- Added preliminary support for campaign maps - currently I've only tested on the first FAF mission (Black Day), and I expect on many maps it won't work properly (due to one of the bugs identified below potentially completely breaking M28 I decided to release earlier than planned as a part-hotfix update). My aim will be to improve M28's performance over time (e.g. currently 1.5 AiX M28 struggles on easy on black day if the human player does nothing). As part of this, M28 allows an AiX on campaign maps of up to 10.0 AiX for the M28 teammate, and will take its share of initial units at the start of a game (since it's not possible to gift units to an AI ally in the campaign)
-
v4 - Campaign and other enhancements
A bunch of bugfixes, tweaks, and some improvements specifically for campaign maps:- 24 bugfixes. The more generally impactful of which relates to the mass/energy stall logic which should now be much more likely to only pause some things rather than everything when stalling
- Quantum gateways and RAS should be built for campaign maps and AiX modifiers (not 1.0 M28 though since I see RAS as too inefficient at that level)
- Reworking of how buildable locations are tracked - originally intended as an optimisation it ended up taking far longer than the previous approach, but I decided to leave it in since it is more accurate and my hope is that it makes late-game major slowdowns less likely than the previous approach.
- Optimisation of nuke targeting logic to reduce how long it can take (at the cost of being less likely to edge-nuke targets), and a number of other functions
- M28 can now capture campaign objective targets. So for example it is now capable (without any AiX boost) of completing FAF mission 2 on easy on its own unaided (i.e. with the human player afk for the entire game).
- Roughly 32 other tweaks/improvements, a number of which are aimed at having M28 better handle very high mass scenarios.
Acknowledgements
- Hdt80bro – helping me find a better way to confirm if a map is a campaign map, and clarifying how to hook orders such as IssueGuard
- Grandpa Sawyer – helping me debug an issue with the base AI taking control of my units (including the IssueFactoryAssist() order being the one I needed to hook)
- Jip – Helping with the same bug as the above, highlighting I was hooking a file that only existed on FAF develop (hence why it wasn’t doing anything for non-FAF develop games)
- Fearghal – replay highlighting major late game slowdown for M28 on Astro Craters Rich
- Wingflier - replay showing M28 losing at 1.5 AiX
-
The campaign AI works pretty nicely, the biggest issues I've run into so far is the AI suiciding to the PD on "Golden Crystal". It happens everytime I tried to play the map, so I think it should be fairly easy to reproduce.
The AI would send their com to the bottom left of top left, tank PD fire then eventully retreat. Then after will they would go back this will repeat. The com normally dying trying to overcharge the PD.
-
@savinguptobebrok Thanks for flagging, I'll have a look for the next version (v7)
-
v5 Release
Main focus was on getting M28 to work ok on FAF mission 3 and some improvements to mission 1 objectives
- 15 Bugfixes
- 11 Misc changes, including a cap on the number of RAS SACUs, and making gunships more aggressive in campaign
- Objectives to repair a damage building (such as the optional one on FAF mission 1) can now be completed by M28
- M28 should treat civilian targets that need to be protected as relatively high priorities for its gunship and asf defence logic
- Resolved an issue on FAF mission 3 where M28 wouldn't build navy until the 2nd objective (the reason was due to it wanting to build its naval factory in part of the map that hadn't yet been revealed)
- Added a unit cap override option in game settings (so M28 can e.g. be given a 1k unit cap) and made 3 improvements to its decisions when near the unit cap.
-
v6 Release
A small release (which doesn't reflect any issues/improvements highlighted the past week as I was away):- Sniperbots should be less likely to move in range of an enemy fatboy
- T1 mobile arti and T2 MML should be more aggressive
- ACU should cancel its upgrade if hit by a TML (such that it is about to die), and should avoid upgrading in range of an enemy TML (that it has identified) unless under TMD coverage
- Added counter to cloaked enemy ACU/SACU that is outside omni coverage
- Increased the amount of SAMs M28 builds both in its base and across the map
- Increased the MAA production by basing the decision on whether there is sufficient MAA on the amount of MAA only (previously SAMs were taken into account)
- 2 Bugfixes, the main one preventing size 1 buildings being built (which meant T1 and hence T2 PD wouldn't get built)
Acknowledgements:
- Azraeelian Angel – Multiple player vs M28 replays, which resulted in most of the changes made this release
- Relent0r – highlighting M28’s ACU could be killed by a single TML firing multiple missiles, and a replay where M28’s ACU would upgrade while taking damage and almost dead.