AI - The Editor

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Ok, I added a more in-depth explanation on how to create conditions.
 
L

LGM

Guest
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. To accomplish this, create the unit in your map, then export it using the Import Manager. Save it in a folder, then reopen the AI Editor to your AI. Click the Import button, then find the data you just saved and import it. It will now be stored in the AI so that you can use it in the coming menus.​

attachment.php



I'm a little confused. Select the unit and then it magicaly appears in the import manager? Could that be explaned a little better.

please?​
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Certainly. What you need to do is:

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, if that helps.

I think I'm going to revise that explanation....
 
L

LGM

Guest
Thanks +rep

EDIT: I would give you +rep, but it says I need to spread some around first...


EDIT2: READ THIS
I have a mac and it changes some things in the editor. If I go to file, Export All ... is not an option. I then went to configure controls. I turned it on, but it still isn't there. I tryed to give the hotkey command A. That just selects all units. Even though I turned that one off too.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Unfortunately, I know next to nothing about Macs. I have no idea what would make it work.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
So? I've added some updates. Anything else to be said? My tutorial feels so lost and alone.... :p
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
AI - Artificial Intelligence

Typically, a computer program designed to perform a task in a similar way that a human would, though with the obvious technical difficulties of trying to teach a computer to "think."
 

Builder Bob

Live free or don't
Reaction score
249
First let me thank you for writing such an easy to read explanation on how the basics on the AI editor works.

However, I can't get it to work properly. In my map, lumber is more important than gold, so I want peasants to start gathering lumber first.

In the AI editor I have set harvest priorities to
8 workers on lumber, then 3 workers on gold.

I have then imported the AI script to my map, and initialized it with a trigger like you wrote.

Unfortunately the starting peasants go for gold first no matter what I do. I have tried to turn off all triggers that initializes any AI scripts and they still go for gold.

Under the Building tab in the AI editor there are some drop down menus that are grayed out for me. Base building, Mine building, Gold worker and Lumber worker. I am thinking that maybe they are refering to default units, and as I am using custom units it will maybe not work as I intend. Do you know how to edit those?

Hope you can help me out.

Edit:

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

I have a custom building classified as a town hall, and I have a custom peasant classified as a worker, but neither show up in the list. What can be the reason for it?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
The AI editor needs to know about it.

The simplest way to get that is to use "file / add to map" from the AI editor.
After that, it will know about your custom units.

The alternative is to export your object date, and import it into the AI editor.
Though you need to redo that for every change... not really recommended.
 

Builder Bob

Live free or don't
Reaction score
249
I had already imported all the object data to the AI editor and could set them in the priority list of what to build when. However, it seems that since I kept the race as human in the general tab, I couldn't change the Base building and workers in the building tab.

When I changed the race to custom, I could define Base building and workers. Now I'm going to set up the building AI again and hope it works.

Edit: By changing the race to custom and setting the base building and workers to custom units, nothing changed. They still went for the gold mine first. However, by deleting the gold mine from their base, I could make them start gathering lumber and play the AI exactly as I had written in the AI editor.

I guess I should make my own thread about my problem, but if you have any ideas of how to make the workers go for lumber before gold, I'd appreciate it.

Edit2: I have figured out the source of my problem. It's one of my triggers that causes peasants to gather around the gold mine.

The easiest way to explain it is that I'm trying to make a similar system of that in starcraft, where every race build their own structure on top of the mine before they start gathering. Therefor I made a trigger that changed any order except build orders targeting the mine into move orders. For some reason the peasants are being ordered to use the mine (maybe it's something the computer does at map initialization to see if they have a mine nearby?) before they head for the lumber and consequently gets stuck in a move order targeting the mine. When I deactivate the trigger they always get lumber first as the AI script says.

I must try to solve the problem some other way now.
 
A

aChiLLeS

Guest
Once I modify the objects... (Let's say i want to create IA that would control Blood Elves) - human buildings, the way that they would produce blood elf units and use different upgrades... I just export the object settings in general, right? So that I can use them in AI editor later on?

One more thing, is it possible to modify the race icon, that appears at the score screen after the game? There are four standard icons available, but in the campaign there were special icons for Naga or Blood Elf... Is it somehow connected with AI editor? I didn't notice such an option in any of the triggers.

Finally, can I make the AI sort of "ignore" certain units? Normally it will probably gather all the units round the town hall... but let's say I would like to place several of his units in different places on the map - is it possible for the AI to ignore them? And is it possible to specify regions in which AI will constantly rebuild destroyed towers for instance?

Hope to get some answers.
Regards ;p
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
> I just export the object settings in general, right?

You probably want to import the settings into the AI Editor.

> is it possible to modify the race icon

You could probably replace the icon for a certain race, but I don't think you could add one.
The replacement would probably be done in Advanced -> Game Interface.

> Finally, can I make the AI sort of "ignore" certain units?

I don't think so, though you could use a "dummy" player that's allied to the computer.
 
A

aChiLLeS

Guest
Ok, with the icons it really works. For ignoring units, there are some commands among the triggers.

But I have another concern. What if I want to put custom buildings, let's say give the AI-controlled-player a semi-developed base at the very beginning? How am I supposed to modify the priorities of building units by AI? I made one attempt... putting a "condition" to every structure / unit which was about to be trained/built, but was already at the map (it was like "build barracks" condition: "if the number of BARRACKS units is equal 0"). But it turned out that AI didn't build anything. It just trained several Grunts (it was about to control Fel Orcs), peons... made a level one melee weapon upgrade and that's it. While it was about to create a well developed base and an expantion, plus - it should train quite a lot of units. My question is: if I put a building order with no condition, and such a building already exists on the map... will it be ignored and built again? Or will it be ignored in a way, that AI will simply skip the action of building it?
I don't know if I made myself clear :) That's why I would be grateful if you just simply explain to me, how should I edit the priorities of building units for the AI when it starts with custom units/buildings on the map.

Oh... and there's one more thing. How does the process of rebuilding the lost buildings and re-training the lost units of the AI-controlled-player look like? Will it simply try to reach the aim of the final point in the priority of building units, from building tab? Let's say a Watch Tower is destroyed... And the AI had a command at some point to build two watch towers - so will it autmatically rebuild it? And about the units... Will it train the units so that it would have all of those which where mentioned in the building tab? I suppose yes, but it would be nice if you could also say something more about it.

Cheers ;]
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
> AI will simply skip the action of building it?

It should yes.

AI scripts run repeatedly over and over... and, well, if some unit or structure already exists, it simply passes on to the next (if possible).
 
A

aChiLLeS

Guest
Ok I'll try to simply add priorities with no conditions... If it won't skip I'll write again :].

But today I came up with a nother problem :)

What should I do if I want to put an AI player on an island... so that he would have to buy transport ships in a shipyard to reach an enemy base? Or let's say similarily that AI player would have to buy air transport from goblin's to reach the enemy? Do I put a transport ship or sth to the priorities of his build-up and the AI will simply guide his hero to the nearest shipyard to get it? The same question goes, what if I want the AI to purchase battle ships? Note, that I didn't yet try to use transport/ships... maybe it's as easy as it seems, just to put them into building tab ;p but i'd rather ask.

And what about rebuilding the structures? What about the pre-placed custom buildings? Once they're damaged, will the AI rebuild them in the same location that they were earlier? Or will it choose it at random?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
The rebuilding part should work.
Placement though... that's more like "Oh, here's a nice spot" :p

Battleships work like normal units.

Transport ships don't work.
You can instruct your AI to build them, and it will do so, but it won't use them.

Zeppelins work.
There's a target priority for buying them, but you can also train them (recommended).
 
A

aChiLLeS

Guest
Train them, you mean add to the building tab? It will trigger the player to go to the nearest goblin laboratory and recruit a zeppelin, if I understand correctly?

Anyway thanks a lot, I'm going to check all of this soon : ]
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
There's two ways(*) to get Zeppelins.

The ususal "melee" way: there's some shop on the map, you walk up to it, clean up the usual Creeps and buy one.
That's done with the target priority "go and buy a Zeppelin" (actual wording may differ).

The unusual "costum" way: you add the Zeppelin as unit to some Barracks, and build it... same as Footmen or so.


(*) actually, there's three:

The "Underestimated Smart AI" way: if the comp looks like it needs one, some trigger with "Unit - Create"... :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top