Help with beginner AI development
-
After the recent AI tournament I was inspired to have a go at experimenting with AI development to see if I could come up with anything remotely functional, and figured I'd also document some of the steps in doing it to help anyone else who is interested in starting out (assuming I make enough progress for such documentation to be of any use).
Unfortunately I feel I've failed already at a basic first hurdle, and wondered if any of the AI developers might take pity and help me out?
I thought I'd start simple, and just try and adapt an AI's initial build order. I used the MicroAI as a starting point since I understand it's intended for public use for such a purpose:
https://github.com/HardlySoftly/MicroAIMy presumption with how the AI relating to the intial build order worked from looking through the files is as follows:
- AIBaseTemplates\MicroAI.lua lists the various custom builder functions to be used by the AI, including 'MicroAICommanderBuilder'
- AI/AIBuilders/MicroBuilders.lua then sets out what each of these builder functions does. 'MicroAICommanderBuilder' is the top priority, and appears to contain the initial build order in the section beginning BuildStructures = { 'T1LandFactory', 'T1EnergyProduction', 'T1EnergyProduction', .... }
So, as a simple test to check if I was right, I changed it so the first item listed was 'T1EnergyProduction', followed by 'T1AirFactory'. However, on loading up the AI on an (offline) custom game, it would still start by building a T1 land factory.
Other changes I made seemed to have some sort of impact (e.g. to try and change the attacks the AI was sending I started messing around with the "MicroAILandBuilder" part of this file, along with the PlatoonTemplates\MicroAITemplates/lua file, which resulted in the AI massing an army of land scouts to attack with - not quite what I was after but at least a noticeable change! So I don't think the issue is with the changes I'm making failing to be reflected in the mod I then load in the offline FAF skirmish)
Searching for articles that might give some basics of how the AI works I found the below which has a section on AI scripting (in the context of custom missions) and a separate guide which gives an overview/diagram of how the AI works:
https://wiki.faforever.com/index.php?title=Mission_Scripting
https://wiki.faforever.com/index.php?title=AI_Modding
I've also been able to locate the core game files that are part of FAF (i.e. the Lua file within Supreme Commander Forged Alliance\gamedata), but I couldn't find anything else from a skim of these forums and Discord.Is anyone able to help either with my query, or alternatively if there's any material aimed at beginners getting into FAF AI development that might explain some of the basics?
Edit: Thanks for the help everyone - now resolved the issue
Edit2: See my more recent forum post for a link to the current version of the guide:
https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v1-devlog -
-
if you want to know what the AI is actual building and what platoonbuilder is used for it, then you could use my AI mod to debug this.
If activated my mod provides the following debug outputs:
DEBUG: AI Platoon names will show the name of the actual platoon on every unit.
DEBUG: AI BuilderManager will print the actual ordered buildplatoon to the moho debug window ([F9])[Edit] if you need help with debugging, just post your mod here or on discord and we will look at it.