AI - The Editor

Discussion in 'Tutorial Repository' started by Ghan, Mar 25, 2007.

  1. Ghan

    Ghan Administrator - Servers are fun Staff Member

    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.

    A. The General Tab

    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.​

    [​IMG]

    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.​

    [​IMG]

    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.​

    [​IMG]

    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.​

    [​IMG]

    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.​

    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.

    Attached Files:

    • Like Like x 12
  2. raijintatsu

    raijintatsu Guest

    Nice tutorial!

    BTW, does the AI Editor also configure what spells and abilities will be used in an engagement?

    Example: If the Tauren Chieftain has already learned Shockwave and War Stomp, which of the two abilities will he use when he encounters a group of Ghouls? Will the AI instruct the Chieftain to use an ability? Is the AI reliable enough to know what ability is appropriate in a given situation?

    (Or should triggers be used to control the spell and ability usage of units and heroes?)
  3. elmstfreddie

    elmstfreddie The Finglonger

    Nice, never understood that thing (either that or I was a real newb last time I looked at it :p)

    Although it could use more explanation I suppose. Pictures and examples would be a nice touch. +rep anyhow.
  4. Ghan

    Ghan Administrator - Servers are fun Staff Member


    I don't think the AI Editor has the capability to assess a situation and decide which ability will be best any more than the regular melee AI, but it will use the abilities.
  5. raijintatsu

    raijintatsu Guest

    I see. Thanks for the clarification! +rep
  6. master maste

    master maste New Member

    Great tutorial never understood it properly until now, a few things should be fixed, add the pictures into the tutorial so we dont need to open them at the bottom and then read the description and make the headings and sub headings bigger than they currently are. And maybe add some colour to the headings.

    Does this AI only work if the computer was set to play before the game? or for example a player leaves and is converted to a computer player, will the AI still work then?

    Btw +rep :)
  7. Ghan

    Ghan Administrator - Servers are fun Staff Member

    Hm.... Never thought about that, but, yes, if you tell the trigger to run the AI after the human player has left, it should take over, although it may be inefficient. What if the human had built a different hero than the AI wanted? I don't know how that would be handled.
  8. Sir Gordon

    Sir Gordon Decent User (I'm as good as you)

    Very good and helpful, a lot of people need information on the AI editor.

    There you go, your 50th rep.
  9. " it is necessary to import any custom units you will need to create your AI."

    Would care to explain this too?

    Anyway, good tutorial, Might I add it to The Index?
  10. Ghan

    Ghan Administrator - Servers are fun Staff Member

    OK, I added an explanation on that. And sure, you can add it to The Index.
  11. pheonixashes

    pheonixashes Those who misplace trust in gods learn their fate.

    Nice tutorial. I've understood it before, though I haven't really made anything too complex with it yet.

    However, maybe you should include a section for a computer to use triggered spell abilities? I see that question a lot, and it probably might fit in this tutorial.

    +rep.
  12. Ghan

    Ghan Administrator - Servers are fun Staff Member

    I don't think you can modify spells with the AI Editor, as far as telling the computer to use them. I believe the computer will only use spells that come with the hero in the Heroes Tab, so if you have a triggered spell included, it will work properly when the hero uses the spell.
  13. Chocobo

    Chocobo White-Flower

    The AI Editor of Warcraft 3 is not powerful (using WE). The best can be done with JASS Scripts (.ai files), because you can define custom units, custom abilities, and all the blabla.. whereas you can't in WE.
  14. Ghan

    Ghan Administrator - Servers are fun Staff Member

    I'm not sure what you mean.... If you want to use custom units in WE, you just have to import them. If you were going to use a JASS script, wouldn't that involve a bunch of triggers?
  15. Miz

    Miz Administrator Staff Member

    lol same I didn't get the basics of WE and that was AI thank you :D

    5/5 Stars
  16. SerraAvenger

    SerraAvenger Cuz I can

    ^^
    What do you think how the AI works?
    It ARE a bunch of triggers.
    The AI reacts, and does not have patterns (currently. See space invaders for nice patterns ;) )
    And JASS itself can be used to register events sent to the WC3 Engine. That's what it's all about: Triggers, Ai, ...

    And even what you call GUI is nothing else then JASS. It is only slower than 'JASS' becouse it uses functions to call natives, and not calls the natives themselves.

    The same applies to Ai Editor integrated in WE, it only calls functions whenever an event occurs
    (Hero Dies: If the ressources are enough, start to revive him in the altar, for example. Or Check until the ressources are ready.)

    So you could programm an Ai in GUI of WE. Or in JASS in WE. Or using an Ai script scripted in JASS.

    Greetings, Serra
  17. Ghan

    Ghan Administrator - Servers are fun Staff Member

    Bump.

    > It ARE a bunch of triggers.

    Obviously. :p However, this tutorial is showing people how to get started using the AI Editor, not making their own AI from scratch. I would consider the AI Editor easier to use, however.

    > So you could programm an Ai in GUI of WE. Or in JASS in WE. Or using an Ai script scripted in JASS.

    Yes. You could. :D
  18. Magazette

    Magazette Guest

    when i go into ai deitor and tryi to set ai abilities, it comes up with only 10 levels of abilities even tho the max level is 25 on my map and an ability with only 1 level appears 3 times and im not sure why
  19. Ghan

    Ghan Administrator - Servers are fun Staff Member

    Did you import the custom hero with the abilities? It's possible that the AI Editor can't go higher than 10....
  20. Magazette

    Magazette Guest

    oh...how does dota do their ai when their max level is also 25, my map isnt a dota map tho

Share This Page