vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation - Zinc documentation - WC3 Optimizer documentation

AI Editor, a graphical tutorial

Guest · 14409

0 Members and 1 Guest are viewing this topic.

AI Editor, a graphical tutorial
on: January 14, 2011, 09:58:04 AM
Category: Trigger (GUI) Editor Tutorials
« Created: April 04, 2016, 10:24:27 PM by moyack »
« Last Edit: August 06, 2017, 11:36:50 PM by moyack »

Related Topics or Resources



by

AI EDITOR
An easy start to the AI.


By moyack

Recommendations: This tutorial is best viewed in Firefox with 1280x1024 monitor resolution

Index.Introduction.

Due to demand in AI information, I've decided to start a tutorial about the AI editor. I'll do my best to make it as easy as possible, anyways if you have any question, I'll answer it here.

This text will have reference information from this tutorial: The WC3 AI Editor by Av3n which is more related with AI editor functionality.

Let's start.

Starting the AI editor.

To start the AI editor, you should open WE and press [F8] or this button .  This editor is not like the trigger or object editor which require an open map, instead you can create, edit and open an AI independently to any map. But if you have a map open, you can inject the developed AI to the map, making it dependable to the units created there (excellent for AI based on custom races). This option will be explained later.

When you open the AI editor you will have this interface:


Figure 1. AI editor - General tab

This interface shows the General tab, we will use it to set the general configuration and global conditions. Because we want to start quickly with our AI, we are going to set the basic features.

First we need to define what kind of AI we are going to do. If we are going to make an AI using a standard race, we should choose in the race combobox the respective race, or custom if we are planning to make one based on a custom race in a map. If we select a normal race, we won't be able to use units from other races, only the standard, campaign or custom ones for the selected race. Custom race in the other hand allow us to select any unit defined in the object editor.

See General Tab reference


Starting a new AI.

Because an example is a good start in the learning process, we are going to emulate a famous human strategy: Mass sorceress. This strategy consist in reach quickly tier 2 to train the sorceress, and then reach tier 3 to get the master training and make this strategy unbeatable. What we will need? well, besides the sorceress, some units from the barracks, mainly footman for tier 1 that can be replaced by knights in tier 3, mortar team as siege support, some special units like priest, and a good support hero for the casters, in this case it will be the Archmage with its summon water elemental + brilliance aura skills. I've seen this strategy sometimes done with a Blood Mage as a second hero (because it can offer its damaging and disabling abilities as an advantage), so I'll add in this strategy too.

With a defined strategy to make, I'll select Human race in general tab, and set the AI name as: Sheep lovers (Figure 2). With this configuration done, we can go straight to the Building tab.


Figure 2. Our first starting...

What can we see?? Basically there is an interface conformed by two list box, the left one is to define the building priorities and the right one is to define the harvest priorities (Figure 3).


Figure 3. Building tab.


Figure 4. Adding a new unit in the building editor
Why is it called building priorities? what's that?

The AI will build the units following the list order, but if any previous unit or building is killed, the AI will give priority to replace the fallen unit according to the list order.

Now that we now how the priorities work, let's start adding some units to this list. As you can see, the list is prefilled with the main hall and 5 peasants, those units are the first units set in a melee game, and with them we are going to build our town. First of all, we need to build a barrack, a farm and an Altar of Kings buildings. To do that, we select the last unit in the list, right click with the mouse, and we will have a menu with the options (Figure 4). We select Add priority..., and a dialog box will appear: the unit type dialog  box (Figure 5).


Figure 5. Unit type dialog box.

Here we have different options:
  • Town: Here we select in which town we are going to train or build the unit required. The options are: Any (suggested), Main (The town at the player start location), Expansion # (Refers to a mine WITH the town hall), Mine # (Refers to the mine expansion location, not necessarily it should have the town hall).
  • Build: Here we select the unit which we are going to train. Options are: Hero first, second and third (This will be explained later), Expansion Town, Specific unit and Specific upgrade.

Figure 6. Our first buildings
For our example, we are going to order to the AI to build a barrack, then a farm, and then the Altar of Kings, then we must say to the AI to build more peasants, so they can harvest wood. To do that, we select in Town: Any, Build: Specific Unit, and then we select the barrack building. and press OK. We do the same for the other buildings and units (Figure 6).

As you can see, we must do that for every unit / upgrade we want to build. The question is... is there a faster way to do that?? Of course yes :) For the peons, I just select the last peon, and then make CTRL+C (or do right click and select copy in the pop up menu), and then paste it by pressing CTRL+V. Repeat this step until you get 10 peons.

Now let me see if you do the things in the right way. If you add peasants until get 10 units trained, you will see something like picture 7, but if you paste 10 times the peasant (or even better, 18 peasants... YEAHHH), you will have something like the picture 8:

Picture 7 - Added peasants until get 10 of them trained

Figure 8 - Added peasants in excess :P

As you can see in the picture 8, the last peon is shown in red, why?? because  the interface is indicating that the the food produced is not enough to keep the units trained, if you add a food provider building prior to this unit, it will be marked in black again.

Because we won't need that amount of peasants at this level, we will remove them until get 10 peasants (like picture 7). Later we will add more peasants when we manage expansions.

Ok, I think it's time to add some attacking units to this AI, so let's add 3 footmen and the First hero. First add a farm so we can have enough food for the next units, then we must add the first hero, do right click over the last unit in the list and select "add priority...", in the unit type dialog box we select in the Build combobox: "Hero - First", then we make click in . After that, we add the footmen units, I suggest 3 of them. After doing this, the priorities list should look like the picture on the right (Picture 9).

Our first test.

With this small progress, we can do a test to this AI. To do that, you can press CTRL+F9 or this button in the AI editor dialog box. This command will start WE running the plunder isle map. When the AI starts, you will see the sequence in the building process:
  • First it will start the barracks, then a farm and then the Altar of Kings. That's ok.
  • The town hall won't build any peasant until it has started all the prior buildings (according to the priorities list), as soon as the Altar of Kings is started, the AI will construct the peons. This situation can become a disadvantage against the enemy because is time that the AI waste and can be used to get a warrior unit. We will discuss later how to solve this issue.
  • After finishing the Altar of Kings, it starts to train a random hero.
  • As soon as a hero is trained, it will try to get a new gold mine. If the AI can't defeat the enemy, it retreats and it gets more warriors, and it will try again, and again, and again until defeat the target enemy group.

Figure 9 - AI with the first warrior units.
Now we must have several questions: How should we control how randomly a hero is chosen, and which heroes should be chosen by the AI?? How to remove those "dead times" and make the AI faster at training units /buildings?? how to control the AI attacks?? As the Spellbreaker said: Watch and learn.


Hero Settings.

As we know, the heroes in WC3 are a very important component for the game, for its skills and attributes which makes them unique, affecting the game flow for good or for bad. The hero effect in the game depends on the following factors:
  • Heroes selection and order (which hero is trained in which tier)
  • Skills selection in all the heroes
For the AI specifically, the heroes have other important function: they are the leaders of the attacking units. If in the game there's no defined AI heroes, there are many chances that the AI won't attack, keeping sleeping until it's is attacked (without react accordingly).

Now that we understand how important are the heroes for the AI, we are going to check it out the Hero interface. Select the "Heroes" tab in the AI editor and you will see this (Figure 10):


Figure 10 - Hero Interface

Let's enumerate the interface functions:
  • We have a section called "Heroes used" to select which heroes will be trained for the AI.
  • A "Training Order" section where we indicate the chances that the AI will train heroes in a specific order, showing us the different combinations.
  • And finally a the "Skill selection" section, where we define in which order the heroes skills are learned. As you can see, the skills per hero can be different depending of the tier which the hero is trained.
Now... how can we configure this interface according to the AI example?? as you remember, we need to train 2 heroes only. We can set this by assigning in the "Heroes Used" section the third hero as None. When you do that, automatically the interface disable some parts of the interface (very convenient ;) ). After doing that, select in the first choose box the Archmage and in the second one the Blood mage. Then set to 100% the chances that the AI trains fist the archmage and then the blood mage. You will notice that the second option (first bloodmage and second archmage) is set to 0% automatically. The interface should look like this (Figure 11):


Figure 11 - Setting the heroes for the Sheep Lovers example. Step 1.

And the last thing to do is to set the skill learning order for each hero. To do that, we select in the "For Hero" choose box the hero which we want to modify the skills order, and we arrange them by selecting each one and modifying its order with the [Move up] and [Move Down] buttons. For our AI example, we are going to modify the Archmage's skill order to this one (Figure 12):

Archmage Skill order:
LevelSkill
1Water Elemental
2Brilliant Aura
3Water Elemental
4Brilliant Aura
5Blizzard
6Teletransportation
7Brilliance Aura
8Water Elemental
9Blizzard
10Blizzard
Figure 12 - Setting the heroes for the Sheep Lovers example. Step 2.

For this case I consider the Blood mage abilities are ok, but if you want to change them too, go ahead :)

Now that we know how to set up the heroes for our AI, we are going to deal with other important AI Editor feature: Conditionals.


Conditionals.

One of the most important features in the AI Editor is the Conditionals. They can be used to help the AI to take a right decision according to the situation at some point, making more "smart".

Where can you apply the conditionals? they can be used in:
  • General tab:
    • Conditions
  • Building tab:
    • Building Priorities
    • Harvest Priorities
  • Attacking tab:
    • Units
    • Target Priorities
How to add a condition to priorities?? Just select the desired priority and right click over it, you will see the option "Modify Condition..." (Figure 13). As soon as you make click on it, you will see the following dialog box (Figure 14).


Figure 13. Conditional menu


Figure 14. Conditional Dialog Box



Figure 15. Configure Condition dialog box
By default, this dialog box is set to none. In order to create a new conditional, we must do click in the list box, and select "custom", this will enable the button [Configure Condition]. Now you can press it and a new dialog box appears (Figure 15). In this one you will feel familiar, because it's similar to the trigger editor dialogs, the only difference is the kind of data that you can select in it. The comparisons are classified in:
  • Boolean Comparison
  • Integer Comparison
  • And
  • Or
The last two kind of Comparison enable And and Or operations between other comparisons, so you will be able to do complex evaluations. A complete list of comparisons can be found in the AI Editor tutorial by Av3n

I think it's time to do a conditional for our AI example. As you can remember, the AI only will train the first hero if it has built 10 peasants and a farm, as you can see, putting the AI to wait until this is a waste of time, it will be better if as soon as the Altar of Kings is built, we put the hero to train. In order to achieve this behavior, we must change the hero priority before the sixth peasant. If we left the things as is, the other 5 peasants won't be trained until the hero begins its training at the Altar of Kings. So we are going to configure the AI so it will train the first hero as soon as the Altar of Kings building is completed, if not, it will train the other units and buildings.

First we have to put the Hero First priority after the Altar of Kings building, then we select it, and then we do right click over this priority selecting "Modify Condition..."


Figure 16.1
After the AI condition is selected, we change in the Condition list box to Custom. We'll see that the button [Configure Condition] is enabled.


Figure 16.2

Press it and the "Configure Condition" dialog box pop ups. Having that, we select an "Integer Comparison" and we'll see a text in hyperlink showing a dogmatic true 0=0. Let's click on the first 0


Figure 16.3
With the Integer comparison dialog box opened, we browse through the integers functions and select the item with the label "Unit - Total Units of Type - Completed Only". Then we press the  button.


Figure 16.4

Now that we have selected our function, we must define the unit type to be counted. In this case we want to check the amount of Altars of Kings. We make click in the link text, and this will open this window.


Figure 16.5

Now that we have selected that unit type, we will see this dialog box "filled". After this press the  button. With this we have defined the first element of comparison.


Figure 16.6
Now let's define the comparison operator. Select in the "Configure condition" dialog box the Equal to link. This will open this dialog (Figure 16.7). After selecting the appropriate comparison operator (In this case Greater than), press the  button.


Figure 16.7

Because we need to do a comparison to a value greater than 0, we don't have to modify the comparison value. But if you need to change that value, just make click in the integer and change the variable in the value that you need. When you have the conditional set, just press the [OK] button.


Figure 16.8 - Almost finishing the conditional
Congratulations!!! you have done your first conditional!!! Now it's time to save it, so please press the  button in the AI condition dialog box.


Figure 16.9 - Conditional finished... saving time!!
« Last Edit: August 06, 2017, 11:36:50 PM by moyack »



Re: AI Editor, a graphical tutorial
Reply #1 on: June 17, 2012, 11:54:36 AM

Tutorial upadted, now it uses images from this site. I have missing the pictures in the figures 16.6 and 16.7 but I'll redo them as soon as possible :)


Re: AI Editor, a graphical tutorial
Reply #2 on: December 08, 2012, 08:15:40 PM

Some small edits in the tutorial :)


Re: AI Editor, a graphical tutorial
Reply #3 on: December 08, 2012, 11:58:22 PM

Hmm actually this is a lovely model for me, i'd been receiving tons of messages about making a custom ai that is tougher to beat for my dark themed melee maps will probably use this tutorial for my next one. Anyway i haven't read it all yet, but it really is very informative, good job. :D

Chronicles of Darkness
by: SonofJay

A BlizzMod Hosted Project

They can hate, let them hate, make them hate.


Re: AI Editor, a graphical tutorial
Reply #4 on: December 11, 2012, 06:49:08 AM

Go ahead, if you have any question, I'll be glad to answer it :)


Re: AI Editor, a graphical tutorial
Reply #5 on: August 09, 2017, 07:57:39 AM

Tutorial fixed with the original images and adapted to the new WC3 modding interface.


 

Chaos Realm - The world of Game modders and wc3 addicts     WC3JASS.com - The JASS Vault   Jetcraft - A Starcraft II mod