AI - The Editor

Tutorial By Ghan_04

I've noticed that there is next to nothing about the AI Editor in all of this forum. So, I've created an introductory course on the workings of the AI Editor.

AI Editor

1. What is the AI Editor?
2. Why Would I Want to Use the AI Editor?
3. How Does the AI Editor Work?

1. What is the AI Editor?

Simply put, the AI Editor is a tool that allows the mapper to create a custom AI script that can be implemented with any combination of structures and units. You can import any number of structures and units for use in the AI Editor.

2. Why Would I Want to Use the AI Editor?

The primary use of the AI Editor is to create a custom race that a computer player will be able to control. The AI Editor eliminates the need for a huge collection of triggers that would be needed to drive a custom race that the computer knows nothing about.

3. How Does the AI Editor Work?

Or, in other words, how do I create a custom AI? Well, first, we'll take a look at the different tabs in the AI Editor and their different functions, then you should be able to create your own AI.

[INDENT]A. The General Tab

[INDENT]The General Tab contains things that are, well, general. This is where you will declare what race your AI will be, Human, Orc, Undead, Night Elf, or Custom. There are also several options for general operations of the AI that come with their own tooltip and are fairly self-explanatory, so I won't go into detail there. There is also a large window for conditions to be used with construction and attack. These conditions can be used with many different operations of the AI Editor, including building and attacking. To create a new condition, click the Add Condtion button at the bottom. You can then give your condition a name. Click on the Configure Condition button to specify what the condition will do. You can then set up a number of comparisons that the AI will check wherever you wish to use that condition. I will give an example of how to do that later on. Lastly, there is an option for importing custom units. Because the AI Editor is not tied in any way with the current map open in the editor, it is necessary to import any custom units you will need to create your AI. When you create a custom unit that you want to use in the AI, export its data. Do this by selecting the unit in the Object Editor, then going to File -> Export All Object Data. Save that in a folder somewhere. When you go to import it into the AI, click on the Import button, find the file that you just saved, and import it. It should be a .w3o file when you export it. It will now be stored in the AI so that you can use it in the coming menus.


B. The Heroes Tab

This tab is probably the easiest as far as the actual AI Editor goes. It simply tells the three heroes the computer can train and sets up the probability of the order of the heroes as well as the order of abilities that the heroes will learn. Once again, this section needs little explanation, so I will move on.


C. The Building Tab

This is where it gets confusing. The Building Tab is where you control all of the units that will be built by the computer. First, you should tell it what building will be the main hall-type building the computer will use. If you import a building with the classification of town hall, it will appear in this list. You also specify which worker unit will be used for gold and lumber. Then in the big panel on the left, you see five peasants and a hall building. In this panel, you will need to enter EVERY unit that the AI will train and construct. You don't have to worry about replacing units as the AI will do this automatically. Make sure to pay attention to the order in which you train units and construct buildings. You wouldn't want to tell the computer to build a priest before an Arcane Sanctum has been constructed, right? Here you also indicated when the computer should build another expansion town, as well as when the first, second, and third heroes will be built. Food will be kept track of as you add units to the panel, and if it turns red, you need to add another farm-type building somewhere before that last food-draining unit. It is easy to move these "priorities" up and down on the list, as well. An important part of this list is that you can attach a condition to every priority. So, if you want the computer to build its first expansion town only if more than 50 food is being used, you can add this using the General Tab. Click add condition on the General tab, configure it, then right-click on the priority on the Building Tab, and select Modify Condition, then add your condition from the list. The Harvest panel on the right is where you specify how many peasant units you want to work on gold and lumber at each town. Here, you can tell the computer to have 5 on gold at the starting town, 5 at the first expansion, 4 on lumber at the starting town, and 2 on lumber at the first expansion, or however you want to configure it. Just make sure that these units have been added in the panel on the left, otherwise the computer won't know where to get the workers! You can add conditions to these in the same manner as the other panel.


D. The Attacking Tab

The Attacking Tab allows you to configure when the computer AI will attack certain objectives, as well as how many and what types of creatures should be included. By default, there is only one group: the All Units group. This group should be used in large attacks, because it takes all the units. In the upper-right panel, add the units that will be included in the currently selected group from the upper-left panel, as well as how many of each type will be included. You can add more "waves" as you wish, to give the computer more dynamic attacks. The biggest portion of this tab, however, is the bottom-right panel. This indicates which objectives the computer will attack and the conditions that need to be met before each attack is launched. But be careful: if you tell the computer to wait for a Enemy - Major Assault until the food used is over 80, but in the Building tab, the food only goes to 75, the attack will never be launched, because the computer will never build above 75 food. Now, remember how I said that you configure the conditions in the General Tab? Well, here's a practical explanation. Say you want your army to launch a Major Assault, but only if you have at least 5 footman. Then, you would create your condition in the General Tab by going to Integer Comparison, then to Total Units of Type - Completed Only. Then, make it greater than or equal to 5. Click OK, and it should show up in the window. To apply the condition, right-click on the Major Assault in the Attacking Tab, and select Modify Condition. Your condition that you just created should appear in the drop-down menu where it says None. Select it, and your condition is ready to go. The other different targets in the Attacking Tab are pretty self-explanatory.


E. The Test Configuration Tab

There really isn't a whole lot to be said here. In this tab, you can set the different properties for doing a simple test of the AI. I believe, however; that this will only work with the four main races.

F. Importing

This is the last thing you need to do. When you finish your AI, save it, then go to the map where you want to implement it. Use the import manager to import the AI that you just saved. Then use a trigger to tell the computer where to run the AI.[/INDENT][/INDENT]

Screenshots of all the tabs are included. One had to be shrunk to upload it, unfortunately.

I have also uploaded a demo map where I created an AI for the other team. It's actually an old, unfinished map of mine, but the AI is fine.

That's all I have for now. If I have missed something, need to be more clear, or need to answer questions, please tell me, as I expect to add more to this tutorial later. I hope, however; that this tutorial is somewhat helpful.

Click here to comment on this tutorial.
Blizzard Entertainment, Inc.
Silkroad Online Forums
Team Griffonrawl Trains Muay Thai and MMA fighters in Ohio.
Apex Steel Pipe - Buys and sells Steel Pipe.