Competitive AI Step by Step with AI Editor
Competitive AI Step by Step
with AI Editor
In this tutorial I'm gonna show you how to make a good melee AI using the AI Editor, I'm not gonna talk about how the editor works since there are other good tutorials made for that purpose, like Av3n's "The AI Editor".
What you must know to understand and use correctly this tutorial?
1. How does the AI Editor work, if you don't know that, see Av3n's tutorial then come back here later.
2. How do conditions work in GUI Triggering
Another thing: I didn't post any screen of the editor because I have the italian version so it won't help you much, and it may cause side effects like: confusion or learning some italian (both things to avoid xD).
However Sunwarrior25 provided me some screens that will do the job...
I'm gonna base this tutorial on making an AI for a normal Human Race, if it's not what you want (very probably) then adapt this explaination to your needings.
Ok, let's start. We're gonna use the AI Editor page by page, the first page is General,
here we set:
Custom Data: IMPORTANT! The race you're gonna use is a normal race or it has been made modifying the object data? In the first case skip this zone, in the second case, you have to import in the AI editor the .w3o file containing the custom Object Data.
Conditions: Here you set the conditions you're gonna use more that one time in the next pages (except Heroes page), I suggest you to set at least these two conditions:
Attack Possible: (((Total number of Footman units completed) Bigger or Equal to 4) And ((Total number of Rifleman units completed) Bigger or Equal to 3) Or ((Total number of Spellbreaker units completed) Bigger or Equal to 3) And ((Total number of Rifleman units completed) Bigger or Equal to 3))
It's a sequence of "Integer", "And" and "Or" conditions. Why do we have to write all of this? We're gonna set this as the main parameter the AI must use to know when it can attack. Change the underlined fields of this trigger to match it with your race:
(((Total number of T1 Melee units completed) Bigger or equal to X) And ((Total numer of Ranged units completed) Bigger or equal to Y) Or (((Total number of T2 Melee units completed) Bigger or equal to Z) And ((Total numer of Ranged units completed) Bigger or equal to Y)
Footman, Ghoul: X = 4
Grunt, Huntress: X = 3
Archer, Headhunter: Y = 4
Rifleman, Crypt Spider: Y = 3
Spellbreaker, Raider: Z = 3
Night-Elves and Undead don't have a T2 Melee unit, so skip the second part of the condition if you use them, or set at its place the T3 Melee unit.
Hall: (Food Produced) Minor of 60
(60 is the number of food you have after having upgraded the hall to Tier 2 in my example)
(That's not an important condition normally, but if you use Orcs or Humans, expecially Humans (they have Spellbreakers, that are better than Footmen, while Grunts and Raiders have pretty similar statistics), you can write down this condition and use it later to disable the training of T1 Melee units when the food is more than 59, in this way the AI will have more food to train stronger units (10 in this example))
(However, in the case of Undead and Night-Elves, this trigger could need to be adapted (to the number of food produced after upgrading the hall to Tier 3) or removed, due to conflicts that could happen with the "Attack Possible" condition, so remember that if you use these two conditions, they are strictly linked, so if you change the first, you probably should change also the second and vice-versa)
Another condition that is essential, if you use units that are upgraded to others: (like Siege Machines (Humans) or Troll Headhunters)
This example will be on Siege Machines:
Siege: (Upgrade level of Scatter Rockets) Equal to 0
If that's not clear, here is the example with the Headhunter:
Headhunter: (Upgrade level of Berserker) Equal to 0
(You must set this condition to all the units that are affected by that power-up then, after making the AI use that power-up, set the building queue of all the units of the new type that should be trained)
(If you don't set this, at the moment of the upgrade the AI won't find the non-upgraded unit to be trainable, thus blocking all the AI unit training)
Ok, we finished with the first page, and we can go to the second one, Heroes:
Used heroes: Here you set the number and the kind of heroes.
Normal values in Training Order in each field per hero number:
Skill selection: There's not much to say, here you choose how will AI's heroes learn each skil.
Another thing, if your hero has custom abilities and are not shown in this zone, open the object editor, copy the "Hero Skills" field, return the field to its default values, then paste the "Hero Skills" field and export the Object Data again and import it again in your AI editor.
If this method doesn't work, retry a couple of times and it should, if it doesn't work even after 3 attempts, feel free to PM me the map and the ".wai" file and I'll try to fix it...
Third page (CAUTION! This is the hardest part, some wrong inputs in this page and you'll face a high number of bugs), Building:
Harvest Priorities (this is how I set them):
(Lumber Worker numbers should be changed depending on how many lumber they can harvest in one trip)
Faerie Fire (5 Lumber, no trip) : 6 Workers
Peon (10, with trip) : 5-6 Workers
Peasant (10 (Improveable), with trip) : 4-5 Workers
Ghoul (20, with trip) : 3-4 Workers
Build Priorities (The MOST important thing in a whole AI, this is an example step by step (and provided with comments) using Humans):
*In the case of a custom hall, maybe it's better to add a condition: (unless you want them to have a bunch of unused T1 Halls in their base)
((Total number of T2 Hall units) equal to 0) And (Total number of T3 Hall units) equal to 0)
Obviously, set T2 Hall and T3 Hall with the buildings you have for Tier 2 Hall and Tier 3 Hall.
** These are the starting units for the AI, so change them with EXACTLY the same units this AI must have at the map init. And, this way, if those workers are killed, they'll be trained by the hall with an active mine, in this way the AI is more efficient.
*** Remember, this only if you don't want them to continue training Footmen when they have Spellbreakers and then Knights
**** In the case of a custom hall, maybe it's better to add a condition: (unless you want them to have a T2 Hall and a T3 in their base at the same time)
(Total number of T3 Hall units) equal to 0)
***** Here you may think: "What the hell can I do with 6 food?" You're wrong, if you used the Hall condition, you have 16 food avaiable now, also if AI Editor tells you the opposite.
****** When The food needed for the queue exceeds the food created by the AI the lines are written in red, but don't worry since, as I explained before, the AI Editor is wrong now.
Finally the third page (and the most difficult) is ended, now the fourth, Attacking:
The first thing to do is to set Attack Groups, 2 attack groups are needed:
This is the minimum of army that the AI will use, I'd base it this way:
In this group you'll put all the units avaiable for the race
Put as a first wave "Minimum Attack", with a delay of 2, then put "All Units" as a second wave, with a delay of 0.
Set the "Minimum Attack" attack group in this field.
Set them this way:
* "Why this?" Because this way the AI will always have at least 1 mine and, if you're gonna play as an ally of this AI, won't try to steal every mine YOU clear.
** Not an important priority, if you want, you can also kick it out
FINALLY! The End!
After this, this AI Step-by-Step is completed, feel free to use it as a base for your custom AI.
Only one thing: remember to save this AI and then export the ".ai" script, never import the ".wai" file in your map, it works but it contains also the custom object data you used for your AI, so the 90% of its size is useless to the map, import the ".ai" file instead.
Thanks to Sunwarrior25 for the screenshots of the AI Editor.
Edited because: 28-02-10: Fixed a typo and modified the Target Priorities in order to be... better.
Isn't the .wai file automatically created (or imported. one of the two) when you import the .ai file?
No, the ".wai" file is created only by the AI Editor when you save your AI, it is the AI script + custom data. To have an ".ai" file you have to save first, then use the command "Export Script". (or some similar name)
Though, as I said above, both work, the ".ai" file is space saving... :)
EDIT: Found the best way to get rid of the "Hero Skills" bug, updated the main post!
FURTHER EDIT: Just found out that moyack already did a tutorial like this... :emote_sad:
Good point, my bad, turns out the .ai file is imported/created if you import the .wai file. Sorry 'bout that. You were right.
Anyhoo, I made a Custom AI based on my entry for the contest. When I changed the object editor data to include a new spell for the hero (Kyrbi0's "Look Out, Sir!"), it keeps trying to reference the old spell (Howl of Terror). The actual strategy hasn't changed. Any ideas?
EDIT: You could change the tutorial to try to reference a custom race. As far as I know, the AI will automatically use any abilities it has (though I think it might have to be run a few times to get the hang of it). I've also noticed that even if you have 4 computer players with the same exact AI, each on different teams, they'll each behave a little differently.
Was the strategy this?
If you tried this and it didn't work, send me a PM with the map and the ".wai" file and I'll give it a check...
For the first point I think that referencing to a custom race could cause a little confusion, but maybe I could attach a map to make people see how does it work...
For the second one, the same AI acts differently depending on different in-game situations, creep positions, mines owned, number of units owned etc.
That's a good thing, because it means that the AI won't act always in the same way, so the map won't have a always-the-same boring AI...
PM'd. The AI I sent you makes full use of it's race's siege engines, and ignores the caster side of it.
Fixed, I'll send you the files soon on PM. Strangely I only tried the "strategy" and now it works. (I should add that if it doesn't work at the first time, re-trying can give results)
BTW Interesting AI... :emote_thumbup:
EDIT: Reppy button won't let me +rep you again
Maybe I could add screens for the first 4 windows, don't worry for the rep, if you do the screens I guess I should rep you XD
EDIT: So, tutorial updated and Reppy sent. :emote_thumbup:
Some handy hints:
1. putting number of unit = number of unit completed as a condition for all your units helps to make sure the building is producing that unit constantly instead of waiting endlessly for the piroties above to be finished
it's better then staggering your units i.e
cause what happens if one of your footment gets killed? the ai will try to replace your footmen and delay the production of the peasent.
2. having Creep Camp (0-9) as a first attack piroty will make the ai creap out ALL Creep Camp (0-9) on the map before it attacks the enemy even when you have 100 food. really bad if you face an AI which techs up first gets better units then you then attacks you in one wave wiping out your tier 1 units all in one. Baring in mind your AI doesn't kill it's own units so you end up with loads of footmen at 100 food
3. in the above AI, all uou have to do is make sure you kill enough to make it have less then 10 peasents and it won't build anything else until it replaces it's peasents. Blademaster wind walk haress combined with you're producing units and it's not
1. That doesn't matter because when the AI has got the barracks will train both peasants and footmen at the same time.
The priority list is not that strict, after the AI has issued the order with the highest priority, will issue all the other possible orders in the list at the same time.
2. For creep camps you're right, I'll probably add some conditions, but normally this AI loses all the footmen above even before arriving to have a Castle, thanks to attacks to creep camps or fights between other AIs, and if it doesn't, 5 Footmen (10 food) is not that great problem, believe me.
3. in this AI you're assuming that the AI can train only a unit at a time... if a Blademaster kills all the peasants, be sure that the AI will train both peasants and footmen/spellbreakers/knights at the same time, depending on existing buildings and on research values etc.
However, thanks for the tips, I'll see what to modify for the 2nd point.
I just found out today, that you can add the AI to the map without doing most of the export stuff. Just click 'File > Add to map' and specify what path you want it to be. It'll add the AI to whatever map is open in the WE. Still, if all you need is the .ai file, then just delete the .wai file that appears as normal...
Just thought I'd post that bit of info. It's still a smart Idea to save the map, in case you need to change something later. (I dunno, is it possible to do what I just said in... say... 1.21?)
Ha! I got so accustomed to "no new replies" for this thread that I didn't check it in a while, sorry...
And... funny, I never ever seen that command (yes, it works on 1.21b), but it seems it imports the AI Data (.wai file), so I won't suggest that. If someone wants to use it, it's in the AI Editor anyway. :P
BTW, thanks for the new! :)
I cannot review this as I have zero knowledge of AI, so I'm going to find someone who does.
Moyack would know.
So would Archmage Owenalacaster.
|All times are GMT. The time now is 05:13 PM.|
Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services