AoE2DE AI Builder (based on Jan1302's Online AI Builder)

This is a python executable program that can be used to create the AI files needed for basic custom campaign AI. It’s based on the Forgotten Empires AI Builder, but this one can be run offline (tested with Python 2.7.x, may work with Python 3.x). A quick summary of the other differences:

  • FE AI Builder has the option to scale built units by difficulty
  • FE AI Builder has AI cheating options
  • FE AI Builder has an immobile AI option (does nothing, ever)
  • This AI Builder allows for saving and loading JSON files of AI data

I wrote this program because I liked the basic idea of the FE AI Builder, but I wanted an offline program that also explained the mechanics in a way that would be easier for me to understand. I figured I’d upload it just in case anyone else would be able to benefit from it.

Original FE AI Builder (and original version of the “builder” AI libraries) created by Jan1302.


Welcome here and my compliments for your contribution. There’s no better way to learn certain mechanics than by scripting those yourself.

1 Like

What exactly are its advantages over online AI builder, except being runnable offline? You mentioned its missing features. I don’t understand, how saving and loading JSON files helps.

1 Like

After noticing a problem with how naval units were being calculated from an AI I made with this, I went and updated the way it exports the naval/siege unit counts. Hopefully that’s the only place where incorrect data was being used…

Also, I removed the “fortifications” upgrade checkbox, since almost all of the University upgrades are about fortifications. This should prevent some errors in saving the .per files into a scenario, but means that you should double-check the upgrade checks when loading JSON made before the fix. (fort-techs was check #5 of 7, so the last two may be incorrect in loaded files until you re-save.)

can the AI builder tell AI build with increase spacing between their own buildings? they leave a single tile/space between each buildings and to woodlines and constantly blocking themselves with their trade and armies mixed.

is it possible to fix with that with this?

If I had to guess, I’d say the AI doesn’t have enough room to build everything you’re asking it to maintain. If there’s a specific AI scripting value that controls where the AI thinks it should build things, I can potentially add that value to the builder program. (Right now, the code taken from the original FE AI builder has information that keeps farms near town centers or mill and resource drop-offs near the related resource, but I don’t know how the rest is handled.)

Keep in mind that this AI isn’t going to be as robust as the standard game DE AI; it’s mostly to make sure that AI players focus on certain aspects of their economy/military for custom campaigns. If you’re building a complex AI, you may have to add things to the final .per file to get the behaviors you want.

At any rate, I can take a look into what might control where the AI builds military buildings. I can’t promise anything yet, but maybe I can find a way to convince the AI to not crowd itself too much.

1 Like

AI build everywhere though, they dont get limited just in their own starting point. every game we play in blackforest, AI ruins game because of army + building + trade carts blocked each other happens 100% of the game with at least 2 AI or more allied.

also I was told this is hardcoded but I have 0 experience with AI modding yet. if it is hard coded then we are a dead end unless dev changes it, which they havent for over 4 months now…

Apologies in advance for replying to a slightly older topic. I am newer to this forum, and don’t know the specific rules about posting on old topics.

So here is an issue I am having on both the downloadable version and html version. Whenever I use the AI, they never advance to a higher age.

Can anyone explain why this is happening? I don’t have any additional mods installed.


Sorry if I necro this post, however I have a doubt. How can I load an exsisting AI file? I tried convert a .per one in .json but I can see nothing on the interface.

The program is not able to load an existing .per file for editing. Saving and loading .json files uses a specific format, while exporting as a .per file is a different format. In addition, the information held in a .per file can be a lot more complicated in advanced AI scripts than what this program works with, and so it would be difficult to make a .per to .json conversion process.

Short version of what can be done with the program in terms of saving/loading:

  • Save the current settings as a .json file for later
  • Load a .json file created by the program to restore those settings
  • Export the current settings as a .per file for AoE2DE

If you need to edit an existing .per file that was not created by the program, you will need to look into the AI scripting documentation and guides for AoE2 and AoE2DE. If the .per file was made by this program, you may have to just re-do the setup as best you can remember.

Hopefully that information helped. Basically, the program can only load .json files created by itself, which seems to have led to the issue you had.

1 Like

Thank you for the detailed answer! I wanted to open .per files because at the start, using the tool, I was a bit confused about gathering percentages, building to build up etc. Glad we have an offline aibuilder btw, the online doesn’t exsist anymore

If you need to examine or edit an existing AI .per file, you can just use a normal text editor. It can take some time to learn what everything means in the AI script, but that’s the way you can edit from an existing AI personality.

1 Like

Can someone explain what the AIbuilder included in AOE2DE actually is? It doesn’t explain it in the game and when I look on forums I get a lot of conflicting answers.

Is it an ai that learns from you and improves all the time?

1 Like

@JackkelDragon excuse me if I bother you, but I have this error everytime I use your tool and I can’t solve it. What I have to do? Thank you


There are a lot of mistakes.
I tried to create AI. At startup, errors in the script, one after another. It did not start.
I don’t understand why this should be done and spread …

I don’t currently have the game installed to check things, but it’s possible that updates or DLC may have changed the way the game handles these files. I’ll take a look when I get a chance, but it may be a bit before I figure out what could have changed.

As for the 5001 error, make sure the “builder XXX.per” files are in the AI folder. I’m not sure if that’s what the issue is, but it sounds like the game is looking for those files and not finding them.

Also, while doing a test on the script using Python 3.x, I discovered that tkinter doesn’t auto-fill the number entries with 0 in Python 3.x. So when using the current version of the program, make absolutely sure that every number box has a value, or the output may not be readable by AoE2DE. (Some of them do default to 0 during the output phase, but not all of them, which then leads to syntax errors.) I’ll try to look into fixing that when I have a chance, since I don’t really need to have the game installed to fix it.

1 Like