AI Development Guide and M27AI v74 Devlog
-
Here is the one with no mods (Uveso & m27 only)
https://replay.faforever.com/17705860
If you want the game log or crash log let me know.
-
Thanks, looking into it further for some reason v45 was only compatible with the FAF develop version of FAF (hence why my pre-release testing didnt pick up any issues as it was all using FAF develop). I've uploaded v46 that reverts it back to v44, and will either upload a new version if I figure out the cause of the incompatibility, or wait for the current FAF develop changes to be incorporated.
-
Latest changes (v47 summary)
The main focus of this update was on optimisation. Special thanks to Softles who wrote some work scheduler code that I was able to use to try and spread out some of my function calls to improve performance.- Fixed the bug from v45 that would cause every game on FAF standard (not FAF develop) to crash when an M27 bomber fired.
- Added in logic for doing a simple profiling of AI performance which can be run by any AI (even if no M27AI is in the game) - for use in place of a normal AI tourney
- Incorporating Softles' workflow scheduler to the majority of M27's loops
- Further optimisation of functions relating to recording the units in a platoon and calculating the threat of enemies
- Reduction in the amount of error messages displayed
- 3 other bugfixes and 3 other misc adjustments
Overall based on my '4v4 UEF Africa for 10m' benchmark, v47 is approximately 8.5% faster than v46.
Acknowledgements:
- Softles for providing work scheduling code
- Savinguptobebrok and Fearghal – highlighting crashes caused by M27 (in every game)
- Relent0r – Highlighting an issue where the ACU can build T1 power when in a vulnerable position (no change was made as it’d be too much effort for a niche scenario – essentially if all our power is destroyed, and we lack intel, then the ACU thinks there are no nearby mobile enemies and tries to build a pgen, but by that stage it will have lost anyway)
-
Latest changes (v48 summary)
A smaller update that should have minimal impact on how well M27 plays, yet still be one of the more noticeable updates:- Added 21 different messages/taunts to give the AI more of a personality
- 9 bugfixes, including fixing an occasional crash that could happen when checking the pathing of units during the game
- 4 misc changes, including adding support for upcoming FAF develop changes to ensure M27's bomber dodge logic continues to work
Acknowledgements:
- Fearghal for replay highlighting a crash caused by M27's pathing check
-
I've still been playing against M27 with some friends. I haven't shared any replays recently because there wasn't much too noticeable for a while, but we did have a few games in a row on a map generator map in which one of the enemy ACUs just walked straight into T2 point defenses and died. I did built T2 point defenses relatively early but I'm not sure why it didn't retreat once it was getting hurt. This is the replay URL: https://replay.faforever.com/17728462 there were also a few other games on that same map where the enemy ACU did exactly the same thing and died so it seemed to be a recurring issues.
All of my games are titled TyneTest and most of them are against M27 with a few human allies and sometimes M27 allies so if you want extra random replays just search them up. Other than the one issue noted above, the M27 is still giving us novices a run for our money, we often beat it but it does often manage to beat us too by rushing experimentals or T3 artillery.
-
@tyne141 Thanks for flagging - the issue is caused because the ACU tries to retreat to what it thinks is the nearest safe place, but due to the simplified pathfinding approach M27 uses it doesnt realise there are cliffs that will mean the quickest path to the safe place takes it closer to the T2 PD. Unfortunately there's no easy fix for this scenario (e.g. just running in the opposite direction to the PD would cause the ACU to go to the wrong place in other scenarios).
It's been mentioned that there are plans to update the base FAF pathfinding logic so I'm holding off spending time trying to improve the approach M27 uses for now as there's a good chance I'd be switching to the new logic if it's more accurate than my current method
-
Latest changes (v49 summary)
Hotfix for a hard crash:- Fixed crash that could happen in some late-game scenarios (if a pathing check was done on a mex)
- Fixed several issues with norush games, the most noticeable being if a hydro was near the start position but out of the norush range, it'd cause the AI to fail to build any power
- 11 other bug fixes, including one that led to more MAA than intended being built for the ACU early game
- 14 misc changes, including novax and T3 arti coordination refinements, norush improvements (so less mass is wasted before the timer runs out), and increasing the times where platoons will look for enemy naval units (including Seraphim destroyers)
Acknowledgements:
- Teralitha – Replay highlighting a hard crash caused by M27, along with various issues with norush
- Uveso – flagging Teralitha’s replay for me to look at and noting the error code involved was the same as one given when hives are given a move order
- Sorrydough – suggestions on improvements and replay highlighting M27 barely winning a 3v1 on a small map
- Tyne141 – Replay highlighting ACU suiciding into PD – unfortunately this was due to pathing issues so no solution could be found.
-
I've noticed one major vulnerability on many maps that have water in between the AI and player like Flooded Strip Mine: the AI almost always sends the commander through the water towards the enemy fairly early on in the game, it's very very easy to destroy the commander with torpedo bombers because the commander is virtually undefended and cannot get back out of the water in time; my impression is that the commander is programmed to harass early on, but in the case of a map like Flooded Strip Mine, it takes so long to get across to the enemy that the commander can very easily be destroyed with torpedo bombers by the time it gets in the water. The commander isn't much of a threat if it get across to the opposite island at that stage in the game anyway so I think it's quite a risky move for very little reward. Here's an example match: https://replay.faforever.com/17901355
-
@tyne141 Thanks, I'll see if I can make it a bit more timid on larger maps where it has to go through water to get to the enemy (as well as if there's anything I can do about the lag/stuttering which I expect is pathfinding related)
-
v50 - Navy is here!
Introduced navy logic for each faction, including:- Figuring out if it wants to consider going for navy on a map, and if so where to locate its factory
- Deciding on the best time to go navy
- Producing a range of naval units (no shield boats or stealth boats yet though)
- Utilising different tactics based on the naval state
- Per-unit dodge micro (to help survive battleship and Aeon destroyer shots)
- 7 bug fixes and 5 misc changes. One of the biggest behind the scenes changes is a cap on how long M27 will spend rechecking pathing, which should solve issues on some maps that would cause it to pause for a couple of seconds regularly
Despite both the addition of a whole new field of war, and individualised microing of units, M27 runs faster than the last update (which I think will be due to the cap on pathing checking time).
Note that navy is a very tricky area for AI (one of the reasons I've held off introducing it and focused on niche areas from v37 onwards), and this is only the first version of the logic so I expect in some cases it will be worse off than before as a result of this.
Acknowledgements:
- tyne141 - Replay highlighting ACU's vulnerability to torpedo bomber snipe
-
@maudlin27 - example of navy game: I've played a few games with navy now and it seems to be working well. In a few games it has used the missiles on the cruisers to great advantage. Here's a Setons game I just played with 7 M27AIs + me and it seemed to work well; I didn't notice any major mistakes made by the AI; however, two of my opponents commanders were killed on the land bridge by the M27 opposition so they were maybe being a bit too reckless with their commanders: https://replay.faforever.com/17979113
-
V51 released but I'm holding off summarising the changelog for now as I may need to roll back to v47 and scrap the various changes made since then.
A few different players have reported desyncs happening sometimes when playing M27 with more than one human player. If you come across this, please could you send me the replay, and also let me know the last version of M27 you played multiple such games (i.e. games with 2+ humans) on so I can try and figure out which version caused the desyncs to start happening.
So far I've seen it happen from 3m into a game to more than 1 hour into a game, on a variety of maps and gamestates.
-
v51-52 - Navy enhancements and desync fix
- Hopefully fixed a desync that would occur frequently when more than 1 human played a game with M27AI
- 10 other more minor bugfixes
- 9 enhancements to engineer build logic e.g. making them and ACUs start construction sooner, and improving the initial build order (most noticeably when trying to go second air)
- 30 enhancements to naval related logic (including air responses to naval threats), the most significant being a shift in the 'all out' naval attack logic to decide for each unit whether to attack based on its range (so e.g. a force of 5 destroyers and 1 frigate vs an enemy force of frigates should no longer suicide the 1 frigate into the enemy if they're out of range of it)
- 3 other misc changes
Acknowledgements:
- Relent0r – replay highlighting naval game; Alterting me to the desync issue along with several replays
- Theodorex – Noting issues with M27 when T2+ units are disabled.
- Tyne141 – Game vs M27 on Setons
- GreatShrek – noting they’d suffered a desync (would’ve been nice had it been via a message not a review, but their replay made it viable for me to find and fix the desync, as it gave a map where desyncs happened almost every time early game making frequent testing of changes viable)
-
Not sure if this is the right pace to post this, but your AI often transfers resource structures to each other and me unecessarily. It kinda starts a chain reaction, where one will gift some something, and then another ai will gift theirs to that one and so on and so forth to where they all are exchanging resource structures often in order to even things out when its not really needed.
-
@teralitha Have you got a replay as an example? It's meant to transfer power generators to teammates when it would be reclaiming them but thinks the teammate has low power and would be better off having them, but I wouldn't be expecting it to trigger that often (so would probably need a replay to figure out why/if it's something that needs fixing).
-
Yes, here - https://replay.faforever.com/17791454
Its happens just after 10 minutes where a bunch of pgens get swapped around between me and a couple others team mates. I didnt have a problem with power, but for some reason I got a bunch of pgens gifted to me.
-
@teralitha Thanks, I'll update it in the next version to keep the PGens in the 'M27 family' (unless the teammate is about to stall power)
-
Hey guy, just to give a little feedback about how the AI performs.
- Commanders seem just a little bit too careless and go out pretty far from their bases in the early game and get creamed. Now, I know some human players also do this, usually noobs, but M27 is not a noob right
- I feel like the AI plays a little too standoffish for its own good. Im beginning to realize that I can exploit this. For example, Hit and run. While this is effective when attacking, its weak when defending and Im figuring out how to manipulate the AI's behavior when I am making offensive moves. Basically its becoming predictable. Would be interesting if squads of AI units were more randomized in their movements. Sometimes being standoffish or hit and run, then suddenly implementing shock manuever/blitz when you least expect it. Or trying to sneak a platoon of ground units around your flank/rear and hitting your weak spot, which is a tactic that ive found works really well on them, since they tend to focus on the front lines.
- They never build mass fabricators. Not sure if thats a hard thing to get them to do or not. They seem to very rarely make SCU's. Like in my last game, I only saw 1 gateway, on the enemy side, but didnt see any scu from it at all.
- Ive watched enemy experimentals like chickens or cyclops doing lot of circles, presumably attempting to avoid things like t2 artillerly, but sometimes when they have a clear advantage, such destroying half an enemy base, they for whatever reason suddenly turn around and retreat before finishing the job and they might not even have much damage.
- M27 seems to produce a massive overabundance of t3 engineers.
- Also massive numbers of air units and anti air units. I never see just regiments of ground units marching and attacking. The AI always seems to be very air/anti air heavy and quite sparse on other types of units.
-
@teralitha Thanks for the feedback! Some of that's intentional, some I'd probably need a replay to decide if it's intentional or not:
1 - (Replay needed but unlikely to change much) - ACU is meant to be aggressive early game and also if it thinks it's behind in the game. If it's easy to consistently kill them then a replay is the best way for me to see if there're any tweaks I can do to make it slightly harder (although it's the area that's probably got the most code and things to take into account as it's very hard to get the balance right between being aggressive and being too aggressive, so there's a good chance a defeat would just fall under the category of the AI being outplayed).
2 - (Unlikely to change) Unit dependent - if it has units like gattling bots/hoplites then it should always hit and run with them. There was one scenario originally where they'd charge in (if trying to get an ACU kill) but I found it really damaged their chances of killing the ACU. Some attacks will be semi-randomised in terms of the target, but trying to sneak around enemy positions is hard to do and not something I'd be able to implement for the forseeable future (requires much better pathing logic than I use at present).
3 - (Might change in the future) Mass fabs I find to generally be a weak unit as a player and even riskier as an AI (since it'd be easy for a human opponent to suicide a bomber in to start a chain reaction) so while it's down as a possible long term change for my AI to build T2 mass fabs in some niche scenarios it's not a priority. While it should sometimes build SACUs it should do this sparingly as on most maps/scenarios I'm unconvinced that they will help it win so it's currently something it might build if it has lots of mass income and some spare mass, so I expect in the game where it built a gateway it had spare mass when it started buillding the gateway but by the time it finished it was using up all its mass so never had enough to want to start on an SACU.
4 - (Replay needed, planned to change) - I expect this is where it is thinking the enemy might have an experimental and wants to get a second experimental to continue the attack but I'd need a replay to confirm. The logic for this is down as something to be improved at some point due to scenarios like this.
5 - (Replay potentially needed, might change in the future) - I expect this will be where the delay between existing engineers completing 1 building and starting on the next leads to the AI storing up lots of mass, and this triggers building engineers to make use of the mass, but I've not noticed it being a significant issue on games I've seen so would need a replay to check if it's this or something else.
6 - (Air - unlikely to change; AA - replay possibly needed) - Generally my impression has been that it underbuilds AA (particularly when supporting an attack such as an experimental). Until recently it would overbuild AA for its ACU but this was fixed so it should be a more modest amount. However, I expect if you're playing M27 vs M27 then it will be building more AA as it varies the amount of AA based on how much air the enemy has, and since M27 likes to focus on air it results in opposing M27 building more air and AA (essentially all of the M27 AI will end up building much more air units and AA units than if they were fighting against an opponent who didnt focus on air). However if you've got a replay where M27 is fighting against a team with no M27 in it and it's massively overbuilding AA the nI could use a replay to check. -
Sure, here is a game I just had earlier where you can see some of these things taking place https://replay.faforever.com/18000390
Id also like to report, in my current game which is a bit of a water map, there seems to be something going on with my ships. They appear to be being controlled by the AI. I keep telling my ships to do what I want, but then they are getting mysteriously redirected to all kinda of different things and not by me. Also, I disabled unit sharing in the options, but the AI can still do it somehow.