AI Development Guide and M27AI v41 Devlog

11

Following the recent Supreme Computer Cup I was inspired to have a go at developing a basic AI for FAF. As I had zero experience of coding in Lua, I thought at the same time I would write down things as I learnt them to have both a guide for other people interested in getting started in developing an AI, and a dev log for the creation of my AI.

See below for a link to the current AI development guide and devlog:
https://docs.google.com/document/d/1uQlEoN-kti7G2MnhwD60uaaHwVevPNYH/edit?usp=sharing&ouid=100973959280546778272&rtpof=true&sd=true

You can also access the mod on Github:
https://github.com/maudlin27/M27AI

I've copied the current overview from the guide below:

This document is intended to do 3 things at once (meaning it does none of them very well!):
• Act as a guide to people new to FAF AI development, including collating any other useful resources out there on AI development
• Be a sort of dev log of my thought process and development steps for creating my first FAF AI, with extracts of code thrown in
• Form my main ‘todo’ list for further developments of my AI
If you see any errors, or have any comments or suggestions (in particular any AI developers who read this since you’ll probably know better/easier ways of doing things than the methods I’ve chosen) let me know and I can update the guide where relevant.

If you’re here for useful resources and/or details of how to write AI and don’t care about the dev log aspect then just skip to section 2) Setup and background and section 5) Index of useful functions, and/or browse the index for points that may be of interest.

Latest changes (v41 summary)

  • 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
  • 10 Other bug fixes
  • 53 Misc changes, including tweaks to late-game high mass scenarios, and early game raiders and build order

Areas of focus by version (history):
v1-3: Release
v4 - Intel and threat detection
v5 - Use of ACU and hotfix
v7 - Engineers and building upgrades
v9 - Air
v10 - Anti-Turtle
v11-v12 - Pathfinding and misc changes
v13 - Anti-navy
v14 - ACU and mobile shields
v15-v18 - CPU optimisation and hotfixes
v19 - Rally points and air domination strategy
v20 - Late game
v21-23 - Eco management
v24 - Bombers
v25 - Misc
v26 - Nukes
v27 - T3 Arti
v28 - Game options/compatibility
v29 - Optimisation and TMD
v30 - Czar, Soulripper and Defences
v31 - Bombers (again) and TML
v32-33 - Plateaus
v34-35 - Turtling
v36 - Skirmishers
v37-38 - Game enders
v39 - Quantum optics
v40 - Deceiver
v41 - Hives and shield disruptor

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v41-devlog

6
  1. Overview 34
    1.1) AI goals 34
    1.2) Background 35
    1.3) Approach 35
  2. Setup and background 36
    2.1) Lua editors 36
    2.1.1) Intellij IDEA 36
    2.2) Other guides which include a section on AI: 37
    2.2.1) General information: 37
    2.2.2) How AI in FAF works 37
    2.2.3) AI markers and how AI uses them: 39
    2.2.4) Hooking (e.g. replacing/appending existing game code) 39
    2.2.5) Creating custom scripts for Sorian AI: 39
    2.2.6) Pathfinding 39
    2.2.7) How platoons work 39
    2.2.8) AI Research (non-FAF related) 39
    2.3) Lua coding 39
    2.3.1) How to code in Lua 39
    2.3.2) Stand alone Lua code testing 39
    2.3.3) Lua optimisation 40
    2.3.4) Common causes of errors for non-Lua coders 40
    2.4) Debugging in FAF 40
    2.4.1) Console 40
    2.4.2) Cheats 41
    2.4.3) Log window and error messages 41
    2.4.4) Debug window and shortcuts 41
    2.4.5) Platoon names for debugging 42
    2.4.6) Function hooks and identifying infinite loops 42
    2.4.7) Destroyed objects 42
    2.4.8) Fast speed 43
    2.4.9) In-game tools and information 43
    2.4.10) Other shortcuts and game startup options 44
    2.4.11) Suggested shortcut 46
    2.4.12) Using FAF Develop 46
    2.4.13) Error handling 47
    2.4.14) Optimisation – benchmarks and monitoring 48
    2.4.15) Debugging via replay 50
    2.5) AI development discord 51
    2.6) Core FAF Lua files 51
    2.6.1) Accessing core Lua code 51
    2.6.2) Other built in functions 52
    2.6.3) Unit blueprints 52
    2.7) Testing AI against other AI 53
    2.7.1) Simple offline testing 53
    2.7.2) Mass offline AI testing 53
    2.8) Getting started – using a simple AI template as a starting point 54
    2.9) Downloading and setting up MicroAI 54
    2.10) Giving the AI mod your own name 55
    2.11) General - Hooks, and getting the code to recognise if it’s running your AI 55
    2.11.1) Hooking – Unit callbacks/events – applied example 56
    2.12) Github 59
    2.12.1) Github advantages and Github desktop 59
    2.12.2) Linking Github with a local repo via creating your own init file 60
    2.12.3) Pro Git ebook 60
    2.12.4) Git commit messages 60
    2.13) Uploading your AI to FAF 60
    2.13.1) Pre-upload checklist 60
    2.13.2) FAF rules on uploading mods 60
    2.13.3) Uploading to FAF 61
    2.14) Other AI documentation 61
  3. AI changes 61
    3.1) Build order - Changing the initial build order 61
    3.1.1) Adding/removing buildings 61
    3.1.2) Change build order based on map resource positions 62
    3.1.3) Build order conditions 62
    3.2) Build order – ACU builds without moving at start 63
    3.2.1) BaseTemplate 63
    3.3) Build factory and power to benefit from adjacency 64
    3.3.1) Record all mexes on the map, and reference this information 64
    3.3.2) Determine com start position 65
    3.3.3) Identify mexes near to start 66
    3.3.4) Hook onto the core code relating to building a structure at a location 66
    3.3.5) Call build order from custom aiBrain function, to edit how things are built 67
    3.3.6) Adjust build template based on mex location - conditions 67
    3.3.7) Adjust build template based on mex location – build location adjustment 68
    3.3.8) Build initial PGens by existing factory 69
    3.3.9) Adjacency bonus where ACU is away from start location 71
    3.3.10) Referencing unit blueprints for information such as unit size 73
    3.4) Platoons and sending engineers to reclaim 75
    3.4.1) How platoons work 75
    3.4.2) Send the first engineer on reclaim duty 80
    3.4.3) Determine where to send the engineer to reclaim 81
    3.4.4) Identifying reclaim mass value 82
    3.4.5) Find out if a location is accessible by ground: 82
    3.4.6) Mapping reclaim locations and assigning preferred location to an engineer 84
    3.4.7) Don’t send early reclaiming engi if there’s minimal starting reclaim 84
    3.4.8) Issue new reclaim command if engineer becomes idle 85
    3.4.9) Send more engineers to reclaim later (as lower priority) based on the reclaim currently on the map 85
    3.4.10) Send 5 engineers at the start to reclaim and build mexes 86
    3.4.11) Reclaiming trees when no main mass left 87
    3.5) Building and assisting hydro 87
    3.5.1) Check if hydro near start area and have engineer build hydro 87
    3.5.2) Have ACU assist engineer with hydro 88
    3.5.3) Get ACU to continue build order after hydro complete 88
    3.5.4) Subsequent build order changes 90
    3.6) Attack force composition changes and check of AI performance 90
    3.6.1) Build Moar Tanks 90
    3.7) Pre-v1: AI Progress check 90
    3.7.1) Land factory buildings and other build order refinements 91
    3.8) Raiding AI 93
    3.8.1) Raiding behaviour - overview 93
    3.8.2) Queue up move commands for mexes 93
    3.8.3) Identify mexes to target 94
    3.8.4) Locating mexes near to an existing pathing route 96
    3.8.5) Determine when raiders need new targets 97
    3.8.6) Handling complications (stuck units, move orders built on, platoon units dying) 97
    3.8.7) Change factory rally point so units are assigned orders sooner 99
    3.8.8) Making use of platoon names for debugging 101
    3.8.9) Ensure 1 land scout included in each platoon 102
    3.8.10) Use microbots before switching to tanks 102
    3.8.11) Have scouts stay with the platoon 104
    3.8.12) AI scouting, threat detection, and identifying nearby enemy units 105
    3.8.13) Attack engineers en-route: Overview 108
    3.8.14) Tracking when have reached movement points 108
    3.8.15) Determining the platoon minimum range 108
    3.8.16) Identifying nearby enemy units and assessing their threat 110
    3.8.17) Actions based on enemy threat 112
    3.8.18) Avoid attacking enemy mexes for small platoons 113
    3.8.19) Other issues – cheating, walls and min range 114
    3.8.20) Larger raiding platoons 115
    3.9) Large attack wave 115
    3.9.1) Checking when to form a large attack wave 115
    3.9.2) Generalising raider AI 116
    3.9.3) Creating separate platoon AI for the large attack force 116
    3.9.4) Run nearer to base when outnumbered 117
    3.9.5) Recalling nearby raiders to join attack force 117
    3.9.6) Updating threat assessment for ACU health and upgrades 119
    3.9.7) Don’t chase small numbers of faster units 120
    3.9.8) Switch to hunt and kill enemies once reached destination 122
    3.10) Pre-v1: AI Progress check 122
    3.10.1) Summer duel 122
    3.10.2) Theta passage 122
    3.10.3) New issues 123
    3.11) Platoon AI – Generalised approach and further enhancements 124
    3.11.1) Embracing the table 124
    3.11.2) Moving units when shots blocked by cliffs 127
    3.11.3) Anti-stuttering protection 127
    3.11.4) Large attack AI – Rally point for merged units 127
    3.11.5) Raiders assume small numbers of enemies are engis/scouts 127
    3.11.6) T1 Artillery specifically target structures, and spread-attack units 128
    3.11.7) Keep scouts at back of platoon 129
    3.11.8) Platoons with non-Seraphim T1 artillery and no tanks don’t run unless against slower enemy 130
    3.11.9) Factor in nearby platoons when faced with enemies 130
    3.11.10) More T1 arti in platoons once reached certain level of tanks 130
    3.11.11) Don’t treat AA as a direct fire unit when forming a platoon 131
    3.11.12) Build hydro where it’s far away from base 131
    3.12) Expansion bases 131
    3.12.1) Background – expansions and the main base 131
    3.12.2) Having all units treated as available for platoons 132
    3.13) Upgrade ACU with gun and attack 132
    3.13.1) How to upgrade an ACU 132
    3.13.2) Get enough energy to support guncom 133
    3.13.3) Upgrade ACU’s gun once have enough energy 134
    3.13.4) Attack with ACU once upgrade finished 135
    3.13.5) ACU overcharge 135
    3.14) V1-3 release incl AI progress check 135
    3.14.1) Performance – v1-3 of M27AI 135
    3.14.2) Issues and planned improvements from testing 136
    3.14.3) Debug issues and other bug fixes 137
    3.14.4) Attack lauched as soon as ACU gun ready 141
    3.14.5) Default attack-move direct fire units at enemy (attack-move if platoon scattered) 141
    3.14.6) Limit of 1 microbot per early raider platoon, and tank defenders 142
    3.14.7) Skip move location if are closer to the next move location than the first one 143
    3.14.8) Build more engineers if are close to overflowing mass 144
    3.14.9) Add energy storage requirements to ACU initial land factory build order 144
    3.14.10) ACU and Engineers will move near mex to build 145
    3.14.11) Other minor misc changes 147
    3.15) On demand basic pathfinding 147
    3.15.1) Revised approach 147
    3.15.2) Mex raiding path optimisations 149
    3.15.3) Useful maps for testing map based logic 149
    3.15.4) Move to build structure – check pathing 149
    3.15.5) Platoon Merge location – have it check no pathing issues in nearby segments 150
    3.16) AI Overseer - responding to enemy attacks 150
    3.16.1) Overview 150
    3.16.2) Planned initial logic 150
    3.16.3) Run overseer on AI creation 151
    3.16.4) Assigning units to defender platoons 152
    3.16.5) Recording enemy threats 152
    3.16.6) Sending units to deal with enemy threats 155
    3.16.7) Sorting a multi-dimensional table 155
    3.16.8) Disbanded units return to base 156
    3.16.9) Intercepting platoons should leave at least 1 scout when removing spare units 157
    3.16.10) Don’t remove units when in combat 157
    3.16.11) Platoon and other build conditions 158
    3.16.12) Limit number of mobile AA in an intercepting defending platoon 158
    3.16.13) Remove ACU from defender platoon once the threat is dealt with 159
    3.16.14) Don’t have ACU join a platoon if its upgrading 159
    3.16.15) Disabling sorian base manager distress logic 159
    3.17) AI Overseer – Intel and ACU managers 160
    3.17.1) Intel manager - overview 160
    3.17.2) Planned logic – 1-off 160
    3.17.3) Planned logic – recurring 160
    3.17.4) Scout localised platoon AI 161
    3.17.5) ACU manager 163
    3.18) V4 release (incl AI progress check) 164
    3.18.1) Pre-release checklist 164
    3.18.2) AI performance results 165
    3.18.3) Notable issues noted from performance 166
    3.18.4) Resolution of immediate issues/bugs post-release 167
    3.19) ACU –aggression, support and micro enhancements 172
    3.19.1) ACU custom platoon - overview 172
    3.19.2) ACU expansion – choice of location 173
    3.19.3) Platoon completion actions 175
    3.19.4) Expanding more than once 176
    3.19.5) Getting nearby reclaim and/or unclaimed mexes while moving 177
    3.19.6) Assisting hydro construction (reworked) 179
    3.19.7) ACU defender platoon refinements 180
    3.19.8) ACU Scout helper and general scout build order 180
    3.19.9) ACU MAA helper and general behaviour 183
    3.19.10) Air threat assessment and MAA to build (initial) 183
    3.19.11) Large platoon scout and MAA helpers 184
    3.19.12) ACU attacks independently to large attack platoon 184
    3.19.13) ACU Build order tweaks 184
    3.19.14) Aeon ACU gets both gun upgrades 185
    3.19.15) ACU retreat 185
    3.19.16) ACU kiting 185
    3.19.17) Have ACU attack-move if kiting doesn’t return any action 186
    3.19.18) Manual overcharge 186
    3.19.19) Other misc changes/refinements 190
    3.20) V5 release (incl AI progress check) 190
    3.20.1) Pre-release checklist 190
    3.20.2) AI performance results 190
    3.20.3) Resolution of immediate issues/bugs 191
    3.21) V6 - Refinements, basic water based actions, v6 hotfix 192
    3.21.1) Misc refinements pre v6 192
    3.21.2) ACU water based actions – reclaim and move to shore 192
    3.21.3) V6 hotfix 193
    3.21.4) Error fixes subsequent to v6 194
    3.22) V7 - Custom build orders and platoon formers 196
    3.22.1) Proof of concept 197
    3.22.2) Initial complications – LABs and no valid units 198
    3.22.3) Related changes – scout conditions; tracking construction orders 199
    3.22.4) Linking production with threat detection overseer 199
    3.22.5) Increasing indirect fire units based on enemy PD usage 199
    3.22.6) Assign MAA similarly to how scouts are assigned 200
    3.22.7) Platoon former – manually assigning platoons based on threat distance 200
    3.22.8) Try to save raider scouts 201
    3.22.9) Not got enough units for a platoon – send spare units to intel path 201
    3.22.10) Call the platoon former if disband a platoon containing combat units 201
    3.22.11) Platoon merger – Periodically combining attack platoons where they’re nearby 201
    3.22.12) Delayed platoon formation 201
    3.22.13) Factories away from main base or with nearby enemies don’t build engineers 203
    3.23) V7 - Engineer overseer 203
    3.23.1) Overview 203
    3.23.2) Spare engineer action logic 203
    3.23.3) Nearby enemy logic 203
    3.23.4) Unclaimed mex logic 204
    3.23.5) Threat detector – adjust distance calculation and record 204
    3.23.6) Update engineer names to reflect their action 204
    3.23.7) Clear unit actions if factory idle (unexpected bug workaround) 204
    3.23.8) Have ACU assist assigned hydro builder and build land factory 205
    3.23.9) Retain existing engineer assignments in favour of nearest engineer 206
    3.23.10) Power assignment – longer term requirement check 206
    3.23.11) Optimisations and rollbacks 206
    3.23.12) Adjacency refinements 207
    3.23.13) Misc changes 207
    3.23.14) If an engineer changes its action and its being guarded, clear the current action and commands of the guards so they can be reassigned 208
    3.23.15) Consider engineer actions as soon as a factory finishes construction 208
    3.23.16) Constructing building – first check if part-complete similar building 209
    3.23.17) Building more engineers 209
    3.23.18) Engineers take into account ACU expansion path 209
    3.23.19) Initial engineers keep building mexes until they die or half the map is covered 210
    3.23.20) Have engineers queue up nearby unclaimed mexes and multiple T1 power 210
    3.23.21) Build a second power at the same time 210
    3.23.22) Build more energy storage based on power income 211
    3.24) V7 - Building Upgrade overseer 211
    3.24.1) Overview 211
    3.24.2) Refinements 211
    3.24.3) Have engineer overseer switch to assisting an upgrade instead of building a land factory 211
    3.24.4) Pause upgrade if low on resources (and track so can resume later) 212
    3.24.5) Mass stall – pause factories over mexes 212
    3.25) V7 - Idle platoon 213
    3.25.1) Army pool platoon and new idle platoon 213
    3.25.2) Approach 213
    3.26) v7 - Misc changes 213
    3.26.1) ACU is removed from defender platoons when allocating new threats 213
    3.26.2) Allocating overseers to different ticks 213
    3.26.3) Have defender platoons move in formation 214
    3.26.4) State of game log 214
    3.26.5) Intel path – allow scouts to move +/- 1 path 214
    3.26.6) ACU shots blocked 215
    3.26.7) Enemy ACU threat increase 215
    3.27) V7+V8 release (incl AI progress check) 215
    3.27.1) V7 - Minor enhancements to overseers due to testing (pre-release) 215
    3.27.2) Tracking revision 216
    3.27.3) Choosing nearby engineers based on mex location 216
    3.27.4) Pre-release check results 217
    3.27.5) V8 Hotfix – crash 217
    3.27.6) Other bugs – fixed in v9 218
    3.27.7) Other misc changes for v9 221
    3.28) V9 - Air scouting 222
    3.28.1) Determining when we last scouted an area 222
    3.28.2) How often we want to scout areas 224
    3.28.3) Deciding on nearest mex targets 224
    3.28.4) Deciding which area to scout first 225
    3.28.5) Adding via points to journey 225
    3.28.6) Take a detour if a scout has died 226
    3.28.7) Produce air factory 226
    3.28.8) Ignore locations too far away 226
    3.28.9) Number of air scouts wanted: 226
    3.28.10) Air factory unit builder 226
    3.28.11) Available scouts – factor in fuel and make use of air staging 227
    3.29) V9 - Air overseer – Bombers and Inties 227
    3.29.1) Generalised scout/air unit management 227
    3.29.2) Find targets for bombers 227
    3.29.3) Determine available bombers 228
    3.29.4) Assign targets to bombers 228
    3.29.5) Bomber production 228
    3.29.6) Make mexes nearer enemy base high priority scout target if idle scout and bomber 228
    3.29.7) Target power if no other targets 229
    3.29.8) Interceptor basic logic: 229
    3.29.9) Interceptor tracking: 229
    3.29.10) Inties built if not enough to meet current air threats 229
    3.29.11) Don’t build bombers if last 3 that died were ineffective 229
    3.30) V9 Release 230
    3.30.1) Pre-release checklist 230
    3.30.2) Post-release bug fixes 230
    3.30.3) Misc tweaks 232
    3.30.4) Initial build order done via my code 232
    3.31) V10 - Air overseer – minor enhancements 233
    3.31.1) Air scouts clear current target if it’s already been scouted recently 233
    3.31.2) Stop inties chasing enemy air to other side of map 233
    3.31.3) Send idle air units to refuel if they have <70% fuel or <80% health 233
    3.31.4) Surplus bomber attack 234
    3.32) V10 - Indirect fire units 234
    3.32.1) Indirect fire overseer/enhancements to threat detection 234
    3.32.2) Prioritise shields and TMD if near current target and wouldn’t cause us to come within range of an enemy PD 238
    3.32.3) Instead of using the average position of a platoon, use the position of the front units 238
    3.32.4) Improved ACU protection logic 239
    3.32.5) Raider/large related attack/run logic 239
    3.32.6) Pathfinding issues 240
    3.32.7) Disband indirect defenders if their current threat group is all dead 240
    3.32.8) Don’t issue override orders from the overseer if a platoon is attacking or running 241
    3.32.9) Syncronised attacks 241
    3.32.10) Include nearby defensive type structures when assessing PD threat 242
    3.32.11) Minor refinements 242
    3.32.12) Escort expanding engineers with 1 tank 242
    3.32.13) Remove escorts if too many 243
    3.32.14) Target upgrading ACU 243
    3.33) V10 - Strategic choices – switching to eco 243
    3.33.1) Stop building tanks and upgrade sooner if have map control 243
    3.33.2) Switch to eco if we have no core platoons we want tanks for 244
    3.33.3) Eco strategy – focus on defence with minimal raiders 244
    3.33.4) Upgrade factories to non hq factories once we have an hq 244
    3.33.5) Switch to eco if mex income not increased recently 244
    3.33.6) Don’t upgrade buildings near the frontline 244
    3.33.7) After upgrading a factory, build an engineer and power as a high priority 244
    3.33.8) Have spare combat units patrol around the mex on our side nearest the midpoint if in eco mode 245
    3.33.9) Keep building tanks in eco mode if we have high mass 245
    3.34) V10 Release 245
    3.34.1) Pre release checks 245
    3.34.2) AI Tournament performance 246
    3.34.3) Bug fixes 246
    3.34.4) Minor enhancements 248
    3.35) V11 - Pathfinding 3rd attempt 250
    3.35.1) Background 250
    3.35.2) Information wanted from pathfinding 250
    3.35.3) Can we path from A to B 250
    3.35.4) Pathing results 258
    3.35.5) Amphibious pathfinding 261
    3.35.6) Naval pathfinding 265
    3.35.7) Summary of time taken to generate level 1 pathing 266
    3.35.8) Optimisation – function integration 266
    3.35.9) Update existing code to make use of new logic in place of CanPathTo 267
    3.35.10) Update intel logic to determine intel paths at start of game 267
    3.35.11) Further changes – v11-v12 267
    3.35.12) V13 Issues – Serenity Desert 268
    3.35.13) V13 - Double-check all mex positions are pathable 268
    3.35.14) Manual height adjustment 270
    3.36) V11-v12 Releases – Mass storage, Anti-Nuke, Misc 270
    3.36.1) Further bug fixes 270
    3.36.2) Basic Anti-experimental and nuke logic 271
    3.36.3) Cap mexes with mass storage 272
    3.36.4) Factor in energy income before having engineers upgrade 272
    3.36.5) Other misc changes 272
    3.36.6) V12 release: Pre release checks 273
    3.36.7) Bug fixes 274
    3.36.8) Misc changes for v13 275
    3.37) V13 - Anti-Navy logic 276
    3.37.1) Navy threat detection overseer 276
    3.37.2) Build more air factories if significant shortfall in air units wanted 277
    3.37.3) Build radar at base once we have enough power 277
    3.37.4) Only produce amphibious land units if we can’t path to the enemy base 278
    3.38) V13 Release 278
    3.38.1) Post release bug fixes 278
    3.38.2) Misc changes 281
    3.39) V14 - ACU Upgrades 283
    3.39.1) Issuing an upgrade 283
    3.39.2) ACU requests help when damaged 283
    3.39.3) Mid-tier ACU upgrades 284
    3.39.4) Only upgrading if we can attack approaching enemy units 284
    3.39.5) Spare engineers don’t assist anything if ACU upgrading and we have low mass 284
    3.39.6) Disable reclaim and building functionality if ACU has big gun (sera+cybran) 284
    3.39.7) ACU won’t get slow upgrades unless it’s closer to our base than the enemy 284
    3.40) V14 - Mobile shields 285
    3.40.1) Shield platoon 285
    3.40.2) Shield production: 285
    3.40.3) Assign mobile shields to T2+ mexes if TML detected 286
    3.40.4) Other platoon changes 286
    3.40.5) Misc changes 286
    3.41) V14 - Assign land scouts to mexes 287
    3.41.1) Assign scouts to mexes and adjust upgrade logic 287
    3.41.2) Build scouts based on numbers needed 287
    3.41.3) Create new platoon logic for guarding a mex 287
    3.41.4) Only upgrade mexes if they are close to base or have intel coverage 287
    3.42) V14 - Anti-bomber logic 288
    3.42.1) Micro to dodge bombers 288
    3.42.2) Working out the position a unit is facing, and how that compares to another location 288
    3.43) V14 - All-in attack on ACU 290
    3.43.1) Deciding whether to launch an all-in attack 290
    3.43.2) Platoon and unit actions 290
    3.43.3) Production and upgrade logic 291
    3.43.4) Platoon formation 291
    3.43.5) Misc refinements 291
    3.44) V14 Release 292
    3.44.1) Pre-release checks 292
    3.44.2) Bug fixes post release 292
    3.44.3) Misc changes/tweaks 294
    3.45) V15 - Profiler 296
    3.45.1) Profiler 296
    3.45.2) Function count and time per tick 297
    3.45.3) Initial results (with no optimisation) 297
    3.45.4) Softles profiler 304
    3.45.5) Conclusion – functions to focus on 306
    3.45.6) Optimisation: Reclaim 306
    3.45.7) Optimisation: GetIntelCoverageOfPosition 306
    3.45.8) Optimisation – high usage functions 307
    3.45.9) Optimisation: GetNearestEnemyIndex 308
    3.45.10) Optimisation: AddNearbyUnitsToThreatGroup 309
    3.45.11) Optimisation – moving near a target and initial optimisation results 309
    3.45.12) Optimisation – GetPriorityExpansionMovementPath (part 2) 310
    3.45.13) Results of optimisation to date and reclaim adjustments 311
    3.45.14) Summary of time taken by different logic areas 316
    3.46) V15 - New reclaim logic 316
    3.46.1) Shortlist of reclaim locations 316
    3.46.2) Assignment 318
    3.46.3) Localised reclaim logic 318
    3.46.4) Reclaim tracking and checks 319
    3.46.5) Other Reclaim functions 319
    3.46.6) Further optimisation 320
    3.47) V15 Release, and v16-18 Hotfix releases 321
    3.47.1) Pre-V16 release bug fixes 322
    3.47.2) Pre-V16 release misc changes 322
    3.47.3) Intel path rewrite 322
    3.47.4) V16 Hotfix release 323
    3.47.5) Pre-v17 hotfix release bug fixes 323
    3.47.6) Pre-V17 hotfix release - Other misc changes 324
    3.47.7) V17 Hotfix Pre-release checks 325
    3.47.8) V18 Hotfix 326
    3.47.9) Post v18 bugfixes 326
    3.47.10) Misc changes 327
    3.48) V19 - Rally points 328
    3.48.1) Choice of rally point 328
    3.48.2) Use of rally points 329
    3.48.3) ACU Anti-TML Logic – retreat to rally point 330
    3.49) V19 - Air dominance strategy and bomber changes 331
    3.49.1) Conditions for switching to air dominance 331
    3.49.2) Production and upgrade changes 331
    3.49.3) Air AA targeting changes 332
    3.49.4) Bomber targeting changes 332
    3.49.5) Initial build order changes 332
    3.49.6) Bomber – ‘hard to hit’ target logic 333
    3.49.7) Other bomber changes 333
    3.50) V19 Release 334
    3.50.1) Pre-release checks 334
    3.50.2) Post-release bugfixes 335
    3.50.3) Misc fixes 336
    3.51) V20 - Experimentals 336
    3.51.1) First experimentals 336
    3.51.2) V20 Pre-release checks 337
    3.51.3) Progress assessment 338
    3.51.4) Post-release bug fixes: 339
    3.51.5) Post release misc changes: 340
    3.52) V21 - Improved ecoing 342
    3.52.1) Build order and eco adjustments 342
    3.52.2) Powerstall management 342
    3.52.3) Reclaiming redundant buildings 343
    3.52.4) Ctrl-K mexes 344
    3.52.5) Other engineer and upgrade improvements 344
    3.52.6) Tracking eco performance progress 345
    3.53) V21 - ACU protection strategy and v21-v23 release 346
    3.53.1) SML ACU protection logic 346
    3.53.2) Dedicated ACU protection mode 346
    3.53.3) V21 Pre-release checks 347
    3.53.4) Post-release changes: Bugfixes 347
    3.53.5) Post-release changes: Misc 348
    3.53.6) V22 Pre-release checks 350
    3.53.7) Post-release bugfixes 351
    3.53.8) Post-release misc changes 352
    3.54) V24 - Early T3 bomber 352
    3.54.1) Prioritise airHQ if enemy is vulnerable to strat bombers 352
    3.54.2) Assisting HQ upgrades 352
    3.54.3) Initial engineers 353
    3.54.4) Scouting 353
    3.54.5) Factoring in bomber success to air factories wanted 353
    3.54.6) Prioritising power over HQs sometimes 353
    3.54.7) Minor eco improvements 353
    3.54.8) Best bomb location 354
    3.54.9) Clear path for bomber 355
    3.54.10) AirAA Support adjustments 355
    3.54.11) Targeting shielded units 356
    3.54.12) Other bomber and air changes 356
    3.55) v25 – Misc issues 358
    3.55.1) Bug fixes 358
    3.55.2) Initial build order changes 359
    3.55.3) Land combat and ACU related 360
    3.55.4) Intel related 361
    3.55.5) Engineer related 362
    3.55.6) Factory production related 363
    3.55.7) Threat response 363
    3.55.8) Air related 363
    3.55.9) Economy upgrade related 365
    3.55.10) Optimisations 365
    3.55.11) Misc/General logic changes 366
    3.55.12) V25 pre-release checks 366
    3.56) V26 – Nukes, shields and novax 367
    3.56.1) Bugfixes (post v25 release) 367
    3.56.2) Misc changes (post v25 release) 368
    3.56.3) When to start a late game unit 370
    3.56.4) Impact on normal build logic 370
    3.56.5) What experimental unit to build: 370
    3.56.6) Nuke launcher construction logic 371
    3.56.7) Nuke launcher targeting logic 371
    3.56.8) Fixed Shield generators 371
    3.56.9) Novax – decision to construct 372
    3.56.10) Novax - Usage 372
    3.56.11) Pre release checks 374
    3.57) V27 – T3 Arti 374
    3.57.1) Bug fixes 374
    3.57.2) Misc changes 376
    3.57.3) Revised overcharge logic 378
    3.57.4) Failed optimisation attempt 379
    3.57.5) UEF remaining late game logic 383
    3.57.6) Pre release checks 384
    3.58) v28 – Compatibility/game options 385
    3.58.1) Bugfixes 385
    3.58.2) Misc changes 386
    3.58.3) Improved nuke logic 387
    3.58.4) Improved logic where we can’t path to the enemy base 387
    3.58.5) Changing focus when an enemy is nearly defeated 388
    3.58.6) Scenario info settings – non-assassination game modes 389
    Other game setting – Unit restrictions 390
    Extra support for mods 391
    Other game setting support – Norush timer 392
    3.58.7) Pre-release checks 393
    3.59) V29 – Optimisation (again) and TMD 394
    3.59.1) Bug fixes 394
    3.59.2) Misc changes 394
    3.59.3) Identifying sim mods 395
    3.59.4) Random optimisation – GetBlueprint and GetUnitId 395
    3.59.5) Reclaim optimisation (again) 397
    3.59.6) NewMovementPath optimisation 401
    3.59.7) Optimisation – engineer logic – Initial changes 401
    3.59.8) New basic profiling check – total game time 404
    3.59.9) Optimisation - Idle engineers 405
    3.59.10) New optimisation feature – showing the ms at a point in time 406
    3.59.11) Platoon raiding 406
    3.59.12) Anti-Mercy logic 408
    3.59.13) TMD 408
    3.59.14) Pre-release checks 412
    3.60) V30 – Czar, Soulripper and defence 412
    3.60.1) Bug fixes 412
    3.60.2) Misc changes 413
    3.60.3) Enemy cloaked com 414
    3.60.4) Fatboy logic enhancements 414
    3.60.5) Reclaim tweaks 415
    3.60.6) ACU running from enemy experimental threats 416
    3.60.7) Non-UEF choice of experimental 416
    3.60.8) Cybran experimental gunship logic 416
    3.60.9) Czar 417
    3.60.10) Further tweaks to czar and soulripper logic 417
    3.60.11) Building SAMs 418
    3.60.12) Building PD 418
    3.60.13) Pre-release checks 419
    3.61) V31 – Bombers, TML and late-game 420
    3.61.1) Bug fixes 420
    3.61.2) Misc changes 422
    3.61.3) Misc improvements to late game 424
    3.61.4) New bomber logic: Initial bombers 425
    3.61.5) New bomber logic: T1 bombers (general) 426
    3.61.6) New bomber target logic: T2 bomber 426
    3.61.7) New bomber target logic: T3 bomber: 426
    3.61.8) Other air changes 428
    3.61.9) T4 bomber targeting and usage 432
    3.61.10) New Logic for land experimental attacks 433
    3.61.11) Co-ordinated T3 arti and novax targeting 433
    3.61.12) TML 434
    3.61.13) Pre-release notes 435
    3.62) V32 – Plateaus 436
    3.62.1) Bug fixes 436
    3.62.2) Misc changes 437
    3.62.3) Transports 439
    3.62.4) Identifying plateaus of interest 439
    3.62.5) Building engineers and transports 440
    3.62.6) Managing transports 440
    3.62.7) Plateau logic - engineers 441
    3.62.8) Plateau logic - factories 441
    3.62.9) Plateau platoon logic 442
    3.62.10) Plateau logic – other 443
    3.62.11) Pre-release checks 443
    3.63) V33 – Hotfix 444
    3.63.1) Bug fixes 444
    3.63.2) Misc changes 446
    3.63.3) Pre-release checks 447
    3.64) V34 – Firebase and shield assisting 448
    3.64.1) Bug fixes 448
    3.64.2) Misc changes 449
    3.64.3) Dynamic Firebases 451
    3.64.4) Shield assisting/Arti war enhancements 453
    3.64.5) Pre-release checks 454
    3.64.6) Acknowledgements 455
    3.65) V35 – Turtling (i.e. pre-planned firebase) 455
    3.65.1) Bug fixes 455
    3.65.2) Misc changes 457
    3.65.3) Identifying a chokepoint 458
    3.65.4) Factory build conditions and turtle mode 459
    3.65.5) ACU T2 upgrade rush, construction and enemies 459
    3.65.6) Defensive ranges and other changes 459
    3.65.7) Firebase fortification logic 460
    3.65.8) Platoon logic adjustments 460
    3.65.9) Other firebase related changes 460
    3.65.10) Pre-release checks 461
    3.65.11) Acknowledgements: 463
    3.66) V36 – Skirmishers 463
    3.66.1) Bug fixes 463
    3.66.2) Misc changes 464
    3.66.3) Skirmisher overview 464
    3.66.4) Construction 464
    3.66.5) Platoon logic 465
    3.66.6) Improved intel to support skirmishers 465
    3.66.7) Optimisation – skirmisher platoon cap 465
    3.66.8) Pre-release checks 465
    3.67) v37 – Game-enders 467
    3.67.1) Bug fixes 467
    3.67.2) Misc changes 467
    3.67.3) Misc changes – Shields and T3 arti 468
    3.67.4) Misc changes – Air units 468
    3.67.5) Basic mass stall manager 469
    3.67.6) Assist TML 469
    3.67.7) Basic game-ender logic - construction 469
    3.67.8) Basic game ender logic - usage 470
    3.67.9) Quantum gateway and SACUs 470
    3.67.10) Pre-release checks 471
    3.67.11) Acknowledgements 472
    3.67.12) V38 Hotfix 472
    3.68) V39 – Niche units (Quantum Optics) and Bomber Defence 473
    3.68.1) Bug fixes 473
    3.68.2) Misc changes 474
    3.68.3) Misc changes - Losing air control logic refinements 475
    3.68.4) Misc changes – bomber defence 476
    3.68.5) Civilian T1 PD – engineer avoidance and Arti hunting 477
    3.68.6) Quantum optics facility 477
    3.68.7) Unit cap (overall) 478
    3.68.8) Pre-release checks 478
    3.68.9) Acknowledgements 479
    3.69) V40 – Niche units (Deceiver) and Cruiser Defence 479
    3.69.1) Bug fixes 479
    3.69.2) Misc changes 480
    3.69.3) Misc changes – cruiser defence 481
    3.69.4) Deceiver 482
    3.69.5) Pre-release checks 482
  4. Future possible changes 483
  5. Index of useful functions 559
    5.1) Map, game setup and general aiBrain information 560
    5.1.1) aiBrain - general 560
    5.1.2) AI Brain – Economy 562
    5.1.3) Map Markers and start positions 563
    5.1.4) Map size and playable area 564
    5.1.5) Terrain info 564
    5.2) Getting a list of units by category, location, or other method 565
    5.2.1) All units that meet a particular category 565
    5.2.2) Units at/near a location 566
    5.3) Unit information 567
    5.3.1) Units on radar 567
    5.3.2) Blueprints and unit categories 567
    5.3.3) Unit upgrades (enhancements) 568
    5.3.4) See 5.4.10) Other unit commands 569
    5.3.5) Location and pathfinding 569
    5.3.6) Unit’s ai Brain owner 569
    5.3.7) Unit’s current commands and whether it’s alive 569
    5.3.8) Unit bones 569
    5.3.9) Shields 570
    5.3.10) Units with missiles/anti-nukes 570
    5.3.11) Unit resource usage 570
    5.4) Unit and platoon commands 571
    5.4.1) Building 571
    5.4.2) Assisting 571
    5.4.3) Pausing 571
    5.4.4) Reclaim 572
    5.4.5) Factory specific commands 572
    5.4.6) Movement and attack-move 572
    5.4.7) Transport 573
    5.4.8) Combat related 573
    5.4.9) Stopping 574
    5.4.10) Other unit commands 574
    5.4.11) Upgrades and enhancements 574
    5.4.12) Current commands and targets 574
    5.4.13) Unit status 575
    5.4.14) Change a unit’s name 576
    5.5) Platoon additional functions 576
    5.5.1) Units platoon handle 576
    5.5.2) Get AIBrain 576
    5.5.3) Get units in a platoon 577
    5.5.4) Disband 577
    5.5.5) Platoon exists 577
    5.5.6) Platoon position 577
    5.5.7) Get all platoons 577
    5.5.8) Platoon ai plan name 577
    5.5.9) Add units to a platoon 577
    5.5.10) Army pool and removing units from a platoon 578
    5.5.11) Create a platoon 578
    5.5.12) Change or reset an AI plan 578
    5.5.13) Platoon movement formation 578
    5.6) Weapon information 578
    5.6.1) Get a unit’s weapon 578
    5.6.2) Get information on that weapon 579
    5.7) Time and thread related 579
    5.7.1) Game time 579
    5.7.2) System time 579
    5.7.3) Wait/delay the code 580
    5.7.4) Fork thread (run independently) 580
    5.8) Events 580
    5.8.1) Creating custom events 582
    5.9) Other 583
    5.9.1) Visual changes – Draw Circles and Lines 583
    5.9.2) On Intel Change 583
    5.9.3) ScenarioInfo.Options 583

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v41-devlog

0

Not exactly an AI comment, but you wanna have things right, right? 🙂

"Lua" (pronounced LOO-ah) means "Moon" in Portuguese. As such, it is neither an acronym nor an abbreviation, but a noun. More specifically, "Lua" is a name, the name of the Earth's moon and the name of the language. Like most names, it should be written in lower case with an initial capital, that is, "Lua". Please do not write it as "LUA", which is both ugly and confusing, because then it becomes an acronym with different meanings for different people. So, please, write "Lua" right!

1

Thanks, I'll reflect the correct case usage of Lua in the next version of the guide (I'll probably update it whenever I release an AI update so the two are in sync)

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v41-devlog

1

So I decided I might actually post something more relevant 🙂

Full stops vs colons – continuing the above example, oUnit.GetUnitId() will return an error, but oUnit:GetUnitId() won’t.

It's maybe worth mentioning why that happens. oUnit:GetUnitId() is syntactic sugar for oUnit.GetUnitId(self). So if you wanna you the version with . you have to pass self as first arg.

F9 opens up the debug window (you may want to change the game resolution to windowed to more easily access this).

That's a log window, not debug. You can open the debugger with Ctrl+F9 or /debug and that's way better for debugging then trying to print things into the log. Since it works as any debugger you are used to, pauses the execution on the line you seleceted and lets you see whats inside global and local variables.

The below link also appears to give a list of core/global functions that can be used (I’ve not tested these to see if they all work, or even if they’re for FAF rather than SupCom2):
https://supcom.fandom.com/wiki/LUADOC_1.5.3599

It is for FA, some of these functions are documented here https://github.com/FAForever/fa/tree/deploy/fafdevelop/engine

I’m not using Github since I’m working on this on my own, and since I doubt I can get the same ease of use I currently have with changing something offline and instantly seeing the results in-game after a Ctrl+F10 restart. However, Github is used by a number of the AI developers so there’s likely some significant benefits to it.

Git is very useful even if you're working alone, as you have history of changes and you can easily switch to previous versions if something breaks. The game can use files from any location, so for my development, it uses files from my local git repo. It's just a matter of setting your own init file https://github.com/FAForever/fa#running-the-game-with-your-changes

To keep things simple (as I couldn’t get more complex builderconditions{} with multiple variables to work, despite seeing it being used in other AIs people have done)

So build conditions are defined in a table

BuildConditions = {
    {BMBC, 'BaseEngineersEnabled', {self.BaseName}},
    {BMBC, 'BaseBuildingEngineers', {self.BaseName}},
    {BMBC, 'HighestFactoryLevel', {i, self.BaseName}},
    {BMBC, 'FactoryCountAndNeed', {i, j, pType, self.BaseName}},
    {BMBC, 'BaseActive', {self.BaseName}},
},

so here, you have 5 build conditions, each in it's own table.

local BMBC = '/lua/editor/BaseManagerBuildConditions.lua'

first value ( BMBC) in the table is thr path the file you wanna use
second one ('BaseEngineersEnabled') is name of the function in that file to use
third ({self.BaseName}) is table of arguments to pass into that function
AI brain is always passed as first argument, and then all other that you specify in the table

So you could rewrite your example to this:

-- Inside the builder
BuilderConditions = {
    {MIBC, 'Is1NearbyMex', {11}}
},


-- Inside MiscBuildConditions.lua
function Is1NearbyMex(aiBrain, distance)
    local iNearbyMex = MapInfo.RecordMexNearStartPosition(Utilities.GetAIBrainArmyNumber(aiBrain), distance, true)
    if iNearbyMex == 1 then
        return true
    end
    return false
end

This way you can already specify the distance for chehcking the nearby mexes.

Determine com start position

This function should do the trick 🙂
brain:GetArmyStartPos()

To help with this, I first wanted to understand what the various variables feeding into it were, so made use of the log function for each variable in turn; where it returned an error due to being a table value that I was trying to put into the log

Best would be to use the debugger to see whats what, as you can open the tables.
But if you really wanna dump the table into the log you have to use LOG(repr(table))

0

@speed2
Thanks, in particular for the debug window - I expect using that would've drastically cut my debugging time! I'll update for your comments in the latest version.

Unfortunately I can't get the debug window to work for me (I just get an error message) and some other people have had the same problem. Asking in the AI discord Jip thought that you need to do an install from the cd version of the game not steam but that you may know the exact procedure?

Error message below in case it helps:
DebugWindow.png

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v41-devlog

0

unpack this https://mega.nz/file/VlRCXajY#UMsAx9IR1dIOqX72bPpOYytR6FS3zO1DGVPT2AhSPAY
into \THQ\Gas Powered Games\Supreme Commander - Forged Alliance\coderes\Engine

0

@speed2
Don't think I've got that folder with the steam install, I've got the following:
C:\Program Files (x86)\Steam\steamapps\common\Supreme Commander Forged Alliance
(this doesn't have a coderecs folder, and adding one in doesnt resolve the issue)

I've also got the FAF location:
C:\ProgramData\FAForever
same issue as with the steamapps folder

(just in case I also tried the \Documents\My Games\Gas Powered Games\Supreme Commander Forged Alliance folder but no luck).

Is there anywhere else I may have missed for a steam version?

Although I'd hoped I'd got the CDs for both as well, checking I've only got the CD for the original supcom so cant try a fresh install via disc.

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v41-devlog

0

It belong to the game instalation folders, and fast few ppl having this issue resolved it by creating those folders

0

@maudlin27

I am not finished reading your guide, but excellent work so far!

2

v4 changes (in reality v2, but when I uploaded the mod on its first release I had to rush out a couple of hotfixes where I'd forgotten to remove debug logic and accidently introduced a bug that affected all games!)

  • Fixed various bugs (see 3.14.3)
  • Slightly improved pathfinding performance (see 3.15)
  • New AI logic which will detect enemy threats and send units to deal with them (see 3.16)
  • New AI logic which attempts to maintain intel over the map to stop surprise attacks (see 3.17)

I've also updated the guide to reflect speed2's comments (as well as a couple of other minor points/sections, such as a bit on uploading a mod and some tests that I now run before uploading)

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v41-devlog

2

I am stunned.

Really good work, maudlin27!

2

v5 changes - these were mostly about the ACU, making it more aggressive and less suicidal

  • Fixed various bugs and improved some error handling (see 3.18.4)
    ACU improvements (see 3.19):
  • ACU will try to expand to high reclaim or mex locations, while building on mexes it comes across and reclaiming
  • ACU will have scout and MAA support
  • ACU tries to kite enemies it comes across
  • ACU uses manual overcharge to overcharge optimal targets

Also updated the guide slightly to add details of the AI development discord channel in FAF (separate to the main AI development discord), and a couple of common hard crash errors

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v41-devlog

1

v6 Hotfix - My AI broke with the recent FAF patch, so this is primarily to fix that. I was in the middle of more extensive changes so my AI is less stable than I'd like but I figured it's better than a broken one! I've also held off on updating the dev log for this release.

Main changes made:

  • ACU performs better underwater (reclaims units, tries to move to nearby land when it cant shoot)
  • Improvements to ACU overcharge behaviour (it should OC when retreating, and also positions better against enemy PD)
  • Switch to new error handling approach (orange messages now appear in the log with more detail; this also happens when any ACU dies)

Issues currently present I'm aware of (which shouldnt have a noticeably detrimental impact on performance, but will be noticeable to anyone looking at the log):

  • 'MergeLocations' error message on certain maps - should just mean larger platoons dont regroup at a midpoint before attacking
  • 'MexRaider' warning about the final waypoint - in most cases just affects which mexes are targetted (in rare cases might cause a delay in the platoon doing anything)
  • 'Stuttering'/delays in performance on certain maps (e.g. open palms)

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v41-devlog

3

V7 Update - T2 is now here! My changes were focused on creating my own engineer and platoon formation functionality (which took far far longer than I was expecting due to various difficult bugs - a lot of work for not much benefit), but at the end I threw in some basic upgrade logic so my AI now gets T2.

Various bug fixes. More notable ones are that the AI should work better on adaptive maps that 'hide' some of their mexes, and should be less likely to try and build on unpathable mexes
Custom platoon formation and engineer functionality. A couple of more notable features of this are that engineers now work together to build 1 building (e.g. power) rather than independently try and build 5 at once, and factor in what mexes theyre already planning to build on when choosing where to expand
Building upgrade logic - AI will now upgrade mexes and land factories (meaning for the first time T2 units can hit the battlefield!)
Load spreading of functionality to help counter the CPU performance hit of these changes
I've also updated the guide for a couple of points (e.g. including a section on events)

As before, much more detail on the changes/my thought process as I went about implementing them is in the dev log.

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v41-devlog

2

v8 Hotfix - Fixed a game crash that could happen if the AI lost an upgrading building (thanks to relent0r for for flagging there was a crash), along with a couple of other minor bug fixes.

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v41-devlog

2

v9 Reintroduced air units:

  • Air scouts are built to periodically scout locations of interest
  • Interceptors are used to help defend against enemy air attacks
  • Bombers should target enemy units of interest.
  • Air factory should be built early if there's enough power (and by a hydro if one is available)
  • Various bug fixes and small tweaks to behaviour - refer to 3.27.6 - 3.27.7 of the guide

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v41-devlog

1

I admire the guide / developers log that you are keeping 🙂

A work of art is never finished, merely abandoned

4

V10 - Implemented anti-turtle logic:

  • Use of T2+T3 MMLs and mobile arti to break firebases
  • Ecoing (not very well, but better than before)
  • Reduced turtle feeding

Misc changes:

  • Large bomber attack for if we end up with lots of spare bombers
  • T3 air factories can be built/upgraded
  • Support factories will be built/upgraded instead of HQs
  • Higher tier power is built sooner
  • Engineers can request guards
  • Various bug fixes (see section 3.30.2 of the guide)
  • Updated the guide with details on how to run in FAF Develop offline

My AI also has a new icon 🙂

M27AI.jpg


For anyone that's interested in the background to the last 5 versions/2 months - back at v5 I was crushed by gunner1069 (I usually get them to play a match every couple of weeks against the latest AI version) with a simple turtle strategy on Theta Passage - they didnt bother getting any mexes and instead just rushed T2 PD with their ACU and my AI had no answer despite having 4x the mass income. My primary focus in all the versions since then has been coming up with the logic that will give my AI a chance in that scenario.

Unfortunately, a relatively simple plan for a human (dont send units single-file into PD, upgrade mexes and then attack with MMLs) required a bunch of different bits of logic:

  • Checking for PD and running away from it (so the enemy isn't fed kills/mass), without running away when we're already in range of it and able to beat it (I had some frustrating to watch games where my AI would charge in at a firebase, overwhelm the shields, be about to destroy everything, before deciding to run and turning a winning position into a loss)
  • Realising there's PD when it kills our land scouts without being picked up by their radar
  • Making use of air scouts to reveal 'hidden' PD to avoid suiciding units and the ACU into the PD
  • Quickly expanding to uncontested mexes (including on enemy side of the map)
  • Focusing on maintaining map control and ecoing if faced with a turtle rather than trying to break them immediately, which in turn requires various logic for identifying if we're against a turtle, upgrading mexes, building T2+ buildings, upgrading factories, making use of support factories, etc. (I've still not got basic things done like capping mexes with mass storage)
  • Using indirect fire units to attack PD/long range enemy units while both protecting them from enemy mobile attacks, and not suiciding our own units trying to protect them

These changes also mean my AI will be worse in other situations - e.g. against a non-turtle it might choose to eco when it would be able to finish the game by pressing the attack, and it's also still poor at the mid-T2+ stage so extending the game via ecoing means it's more likely to snatch defeat from the jaws of victory. Long term though it needed to happen as a 'T1 or die' strategy only has a decent chance on 5v5 maps.

M27AI developer; Devlog and more general AI development guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v41-devlog

0

@maudlin27 Nice list of g
Changes of updates for you Ai mod, I'd like to extend you the offer it have this in a more of a cleaner formate over on the new faf wiki, if this is somtbing your interested in please send me a pm here or on the faf discord and I can set you up with a page 😀

"The needs of the many outweigh the needs of the few" - Spock