AI Development Guide and M27AI v74 Devlog
-
@splitice said in AI Development Guide and M27AI v15 Devlog:
Liberiam Battles
What were the game settings, in particular what player slots were in use by what teams and/or do you have a replay ID? I tried it just now in slots 1+2 and didnt get an error but from the log extracts and look of the map it might depend on what the player and team setup is.
-
@maudlin27 said in AI Development Guide and M27AI v15 Devlog:
What were the game settings, in particular what player slots were in use by what teams and/or do you have a replay ID? I tried it just now in slots 1+2 and didnt get an error but from the log extracts and look of the map it might depend on what the player and team setup is.
From memory was a mix of Sorian and your 2x m27 aix v 2x sorian aix v 2x sorian aix v1(player)
Just added m27 on a whim so didnt record game settings. Replay is https://replay.faforever.com/16044970
-
@splitice Thanks, found and fixed the issue in the latest version (will upload in a moment). Re Burial Mounds, having a look at the map it's not one that my AI will fare very well on at the moment (confirmed by it losing vs Sorian Adaptive when I tested just now). The biggest issue being the heavily fortified civilian base which will stop some of the ACU rushes that M27 relies on to gain an early game advantage (and which probably is also why it's not ecoing quickly), as well as making its current reliance on land for victory late-game flawed since amphibious tanks dont fare well against significant PD fortifications.
-
v16 - Hotfix:
- Rewrote my land scout pathing logic to fix a bug that caused a crash on Liberiam Battles (thanks @splitice for flagging)
- Minor tweaks to overcharge logic to increase the units that will be considered
- Low health enemy ACUs are more likely to be targeted for an all-in attack even if M27's ACU isn't nearby
- Bugfix to air threat logic so that air units near the ACU are correctly prioritised; also tweaks to the logic for building air factories when outnumbered in air
-
@maudlin27 Re; Burial Mounds if I was to describe the problems with the strategy they would be (in no particular order) - sorry was late.
- Over reliance on light artilery. I (a human player) would see this and respond with a small air fleet and this unit is not particularly useful on a water map. The AIs pumping these out were largely limited to defensive operations.
- After the early rush fails (or if AI suspects it will fail) the AI really needs to switch to economy building first. A player who has a well optimized build queue can easily push many orders of magnitude ahead of this AI
- One of the AIs didnt build any mass extractors, just a single land factory and pumped out units. Given the extremely low cost and quick pay back time of a T1 mass extractor I struggle to see why they should b skipped (of course they could be delayed, but I stopped the game after ~15m and it was still just pumping out units). Perhaps if a early rush tactic is chosen a max game time before mass extractor build within at-least the players own area continues should be implemented?
I havent played against the AI as a human yet so this is theoretical.
-
@maudlin27 said in AI Development Guide and M27AI v15 Devlog:
To give a rough idea of the relative weightings for M27
Thank you for the time you spent gathering this.
That's quite a low % of total time, I assume this is pegged at 100% (i.e max sim speed until saturation)?
In retrospect I wonder what % of time goes to AI vs lua game logic vs engine. I'd always assumed the AI code (being there is multiple instances of it running and they typically can be quite intensive) would be a good (50+%) of the total sim time.
-
@splitice Thanks for the feedback!
- Re 1 - Likely a flaw due to the civilian point defences - the AI treats civilian units as enemies, considers the total weighting of enemy units, thinks its up against an enemy who favours PD far above mobile units, and so builds lots of arti in response. No easy short term solution where the civilian base cant be pathed to (I'd probably need to come up with map specific logic which will be a long way away, or special rules for civilians which would similarly be very low down on my list as this is the largest civilian base I've come across on a map to date)
- 2 - Unfortunately it's not straightforward to come up with an approach/set of rules that would handle this well, and the current approach assumes it should be able to gain map control if it spends more than the enemy on units.
Longer term I'm planning on introducing turtle logic to the AI which I'd probably look to use on a map like this which would make it eco a bit better, but that's at least a few versions away. - 3 - Sounds like a bug - doing a quick test with 8 M27AI, within the first 5m all mexes on each side were either claimed or queued up to be claimed, so I'd need a replay to investigate further. When checking back on the 4v4 test I ran though I noticed some other bugs which led to a massive slowdown/broken AI after certain players died which I'll be looking into for another hotfix!
Re the low profiling, I think the low % of total time is due to the limitations of the method I'm using - while getting the difference in system time seconds gives a good guide of how long a function takes relative to other functions, I think there're other things that happen in the background as a result of the code which don't get picked up (e.g. Sprouto's mentioned there's a garbage collector that can require resources to deal with clearing redundant variables) - these could be linked to the AI, or the normal game engine/operations, and I'm not sure of a reliable way to quantify. However I'd also assume the AI will take a majority of the total sim time, especially where multiple AI are used.
-
V17 Hotfix (Hotfix to the previous hotfix)
My previous hotfix fixed an issue with the AI not working on some maps, but caused it to crash on some teamgame maps. This is now fixed so hopefully it works on almost all maps.
Other minor changes made:- Bombers will try and defend the base if enemies get near
- ACU will overcharge when retreating
- Air factories should be built in priority to land factories if there's a significant air unit shortfall
- Various minor bugfixes (mostly aimed at reducing the error messages appearing in the log when an ACU dies)
Edit: v18 Hotfix - AI should now work when DilliDalli AI is also playing; also fixed issue for maps with >=10 players.
-
v19 Update:
The focus of this release was implementing a new 'air dominance' strategy intended to punish players who don't get AA, and to make better use of rally points.- New air dominance strategy - if the enemy fails to get AA quickly enough the AI will aim to focus all its resources on building bombers to overwhelm them. Related to this I've reworked some of the logic for choice of bomber targets
- Better use of rally points - units will look to gather at a rally point between our base and the enemy, so they are less likely to cause pathfinding issues at base and can respond quicker to threats
- Improved logic for ACU upgrades - fixed some bugs and added new checks so ACU should be less likely to upgrade when near the enemy base, while upgrading sooner if its able to, and attacking the enemy sooner once upgraded
- Various other bugfixes and minor tweaks
The air dominance strategy is mostly a 'win more' strategy, but I've seen a few games my AI has played (both against humans and AI) where it has an initial bomber that does a lot of damage before being shot down, yet eventually the enemy is able to recover from the damage and wins the game. The hope with the air domination strategy is that such games turn into a quick win instead of just a moderate advantage. However it has its risks, since it's incredibly mass efficient to counter air units that are attacking your base, and if you kill them you then benefit from all their wrecks.
-
v20 Update:
This version improves some of the AI's late game ability, both fixing an issue that led to severe under-utilisation of T3 mobile artillery in some cases, and having it build experimental units.- Experimental units will now sometimes be built late game
- Improved use of T3 mobile artillery (they're less likely to gather in huge numbers doing nothing...)
- Better use of heavily upgraded ACUs (including bugfix that caused Cybran ACUs to do nothing after getting laser)
- Tweaks to Engineer management
- Other minor bugfixes
-
v21 Update
This version focused mostly on smaller eco gains so when my AI is trying to eco it should do it a bit better. Main changes are:- Power stall manager to pause construction etc. to avoid or minimise power stalls
- New dedicated ACU protection strategy to provide quicker help to our ACU when its in trouble
- Increased focus on marginal mass gains when ecoing (e.g. not getting as much power so more mass can be spent on mexes; Reducing the combat units built so it can be spent on mexes, etc.)
- Various bugfixes, including one that stopped a fully upgraded Sera com from doing anything, and issues with ACU logic for cancelling its upgrade and running away
Since my ACU self-destruct logic hardly ever triggers (I've only had it work in sandbox when testing it), I also decided to expand the behaviour - now my engineers and mexes should also exhibit self-destructive behaviour.
@jip FYI re your query a few versions ago when I introduced it, my ACU should only self-destruct in the niche scenario where it is about to die anyway and the enemy ACU is within range of the explosion and low enough health to die to it. I didn't want to risk a more general 'I give up' type logic both for fear of hit going horribly wrong, and since even in games where my AI's base has been destroyed it's sometimes managed a win with its ACU.
-
v22-v23 Update
There was no particular theme to these changes, other than that most of them arose from watching mistakes my AI made on a 1v1 against another AI on Burial Mounds- Tanks can now suicide (sometimes)
- Fixed bug with power stall manager that made it far less effective; minor tweaks to this to prioritise HQ updates and initial engineer production (to allow more efficient power)
- Minor logic improvements to experimentals (stopping them from trying to kite, making monkeylord move instead of attack-moving)
- Ignoring PD that cant be pathed by land (so MMLs etc. arent overbuilt trying to counter it - relevant in particular for Burial Mounds)
- Various tweaks to air logic (more likely to refuel, target transports with AA, make use of stealth)
- More accurate logic for whether reclaim is within range (thanks to Marlo and Jip who helped me figure out how to determine the size of a reclaim object)
- Another rework of my land scout 'intel path' logic - it should now form a path along the shoreline on island maps
- Bugfix that caused my threat response logic to view each unit individually instead of grouping threats together
- Various other bugfixes and tweaks
Although there was no big area of focus with this release, I did manage to achieve one of my long term goals with it, beating gunner1069 (the human sparring partner who usually plays a match against each version of the AI; they're a 1.1k global from playing astro exclusively, with their preferred tactic being to turtle - originally they played M27AI on Theta Passage, until around v10 when M27AI would fare well against their turtling on conventional maps, at which point they switched to Astro Craters).
Winning against a turtle on Astro Craters is harder than a normal map, since the normal advice against a turtle is to avoid attacking them, out-eco them with your map control (since T1 mexes are far cheaper per mass generated than T2 mexes), and then attack with an overwhelming force. Obviously this doesn't work so well if gaining map control just means you have 21 mexes to their 19. There are still plenty of flaws with my AI that a good astro player could exploit to win, but it can now at least offer a challenge on the map against weaker players.
V23 hotfix - Thanks to relent0r for flagging - there was a bug in v22 which caused my T1 platoon formers to not work, which should be fixed now.
-
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
-
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.
-
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.
-
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.
-
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!
-
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
-
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.
-
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)