WIP Creating a Non-Melee AI - Tutorial Work-in-Progress

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Why make a tutorial on making an AI?

Well, so many maps have AI's, yet not one of them uses the AI editor in game. Games like Castle Fight, Multi-Square Defense, and others have their own AI systems. Many people play games with AI's in them, and when they go to make their own map, they assume the game AI can already do everything. So, many of those people will come onto a forum like this one, asking how to get their "AI" working, when their hero isn't automatically collecting items and using his abilities. This tutorial teaches you about AI's, so that when you want to make your own, you'll know just where to begin!

Note: This tutorial is a Work-In-Progress.

Non-Melee AI Tutorial

Ever wanted to create an AI, or bots for your game, but the AI editor was insufficient? This tutorial will teach you how AIs work, and how to program one.​

The Basics

An AI is basically something that controls units. Whether it controls buildings, regular units, or heroes, it can all be programmed into one AI. An AI is not magical, and there is a very limited amount of what a computer can do without the aid of triggers, so understand that your AI system will take a lot of work. You will use variables and if-then-else conditions constantly in order for your AI to be able to make choices based on its environment.​

How does an AI work?

An AI is not an actual person and thus, must be thought of as a collection of current conditions, objectives, and rules. For example, if a Melee AI has two thousand gold, its current condition might be 'rich'. Objectives of an AI can be scaled down to smaller and smaller decisions. For example, a large scale objective is to wipe out all other players. This can be scaled down to 'Assemble an army to attack the enemy', and further down to 'collect resources, research requirements, and build barracks in order to train an army'.

  • These same concepts can be applied to any map's AI. For example, if you were making a bot hero for DotA, you might want to take in account a hero's Health, gold, available abilities, and current items as conditions. If you leave out one, you are crippling your bot. For example, a hero's health is necessary to know in order for the bot to know when to retreat to heal. Gold is necessary for the hero to know when he can go back to purchase items. Available abilities are necessary to know if its possible for a hero to 'sprint away' or severely cripple an enemy hero. Items are also necessary, so a bot knows if it has some of the necessary components for a recipe, or if it has any special abilities.
  • The objectives of a DotA bot are relatively simple at first: Destroy the enemy base. However this can be broken up into many smaller objectives, such as destroy the tower, push one lane, retreat to fight later, or even as having a doomed hero using all of its abilities, since it will revive with full mana and cooldowns.
  • The AI also has rules to follow. Going solo can be less beneficial to the team, compared with working with another hero to push one lane. Buy items cautiously, as you can only sell items for half of what they cost. These are basic rules that an AI should be 'aware' of. Rules are basically just evaluations that tell the AI what the best course of action is. Obviously, a bot shouldn't just pick any random item. He should choose the one that makes him strongest, or has the most potential. Another way to look at rules, is to make the AI not do what a person wouldn't. Obviously, it's not going to be sensible for a player to switch lanes in DotA, if he has to run all the way back to his base first. It would just be a waste of time. Make your AI able to understand the obstacles and mechanics of the game that players naturally understand. Your bot will have to understand the pathing of your map if it is going to be moving around within it.

Foundation Tips

Just as your map started out somewhat basic, and got more complex as you learned what was good and bad, so your AI will have to start out basic. However, no one wants to have to recode things constantly. It's best to start out with a strong foundation.

  • Another tip for creating a good foundation, is to start small. No one writes a complicated AI script in a day. Start with the very basics, such as creating waypoints for units, and have units auto-attack. Scripting the actual combat decisions of a bot can be confusing, tiresome, and can easily result in a buggy AI.
  • One good way of coding a good foundation is to write everything that could change in its own function. Try to reuse code as much as possible, so that if you happen to need to change something simple, such as knowing whether a unit is "threatened", you only have to change it in one place. Later on, you may discover that the condition is more complicated than simply checking if there are nearby enemies.

A few things to know about writing an AI, is that you will be working with events and condition functions (in your code) much more than you probably did before. You will want to keep your code readable and easy to change, so you should use events to change variables and information about the game. Then you can use them to run evaluations which update units orders.
 

RaiJin

New Member
Reaction score
40
sweet this looks interesting im looking foward to seeing the rest of it completed
+rep just for the startoff:thup:
 

black.sheep

Active Member
Reaction score
24
Could you give us a simple AI that protected a tower, ran back to a fount to heal, and used spells?
 

TideOfChaos

New Member
Reaction score
25
This is a good start, you establish all the ground basics and what not.

Now I suggest giving an exsample of some simple combat AI - Engaging, Presuing, Disengaging.
 

wraithseeker

Tired.
Reaction score
122
Darthfett, you as a moderator should have read this rule :p

Rules said:
Only submit complete resources - do not put anything unfinished here. This includes, but isn't limited to half-complete tutorials, WIP spells, "will upload it tomorrow" systems and similar submissions. If you want to promote your unfinished work then there are other forums for that, namely Members' Projects
 

Azlier

Old World Ghost
Reaction score
461
Zat rule faded into history many centuries ago.

Non-Melee AI is always hard to pull off. You have to trigger the whole thing! Not fun. Good luck with zis tutorial.
 

esb

Because none of us are as cruel as all of us.
Reaction score
329
Well, it is basicly completed (haha, get it? BASIC, as in Tutorial for Basic AI?). Well it's just a short tutorial and what AI's have in general. Which probably isn't much in order for it to get approved, but it's here.

Not bad though. I always thought AI's were such a pain, as they require (depending on the map) many fool proof conditions for different, specific, scenarios...
 

Flare

Stops copies me!
Reaction score
662
Darthfett, you as a moderator should have read this rule :p
Ahm... search the Forum Leaders page and find any category (or categories) that Darthfett is under... he's not a moderator (yet :p)

But ye, as it is right now, it's nothing more than a description of what an AI does and a brief overview of how they work. If you want, I can move it to Member's Projects, for the time being, until it's more complete
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Wtf? I thought he was one judging from his repuatation.

No, I am not a moderator. I'm just a regular here. :p

wraithseeker said:
Darthfett, you as a moderator should have read this rule :p

I know, but I wanted to get this up here with the formatting. It's much easier to format while I write.

Yes, the tutorial is rather short right now, but it will be MUCH longer by the time I'm through with it. ;)

Could you give us a simple AI that protected a tower, ran back to a fount to heal, and used spells?

This tutorial isn't intended to actually go into that much depth. This is more of a 'design' tutorial, where you will learn where to begin, so that you don't start out on the wrong foot. Although I will give many examples, I don't think an actual AI will be one (although I am making an AI for my Forest CTF map that will parallel this tutorial).

Now I suggest giving an exsample of some simple combat AI - Engaging, Presuing, Disengaging.

That is only one form of AI, and I don't plan on going into that much depth. This is actually a pretty complicated task, and explaining it would take pages and pages. Instead of boring you, I plan on keeping the tutorial to a minimum, and giving you ideas for your own. Since AI's are different for EVERY map, I have to keep this very general.

esb said:
Well it's just a short tutorial and what AI's have in general. Which probably isn't much in order for it to get approved, but it's here.

Not yet, it's unfinished anyways. Plus, this is just the 'Intro' to the actual tutorial.

esb said:
Not bad though. I always thought AI's were such a pain, as they require (depending on the map) many fool proof conditions for different, specific, scenarios...

Yep. That is why AI's are so complicated and take so long to make. That's why I want to make this tutorial, to ease the process of designing it, so you can focus on what you need to (making the design work for YOUR map).

Thanks for all the comments, guys! :D
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
It's always great to see AI tutorials, but I don't like it being here in it's WIP state.

I'll move it to the Members' Project forum and add a WIP prefix, if you don't mind.
 

Sid

Member
Reaction score
5
Okay, this can be of little help, You know...
I have an AoS in progress and have many assault and escape routes.

So I'd be a haapy person if you could write a few things about...
1. AI preperly choosing route of assault and escape
2. AI using Custom Spells with indicated methods
3. AI helping teammates, rather than playing for himself.
4. AI' Misc behaviour, like Last hit kills / denies, Defending base and etc. etc.
 

Septimus

New Member
Reaction score
58
This tutorial forget to mention 1-2 thing.

An AI should be categorize into 3 difficulty. Easy, normal and insane. A map should not contain a AI whenever any difficulty of the AI choosen, the AI are still acting the same.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
It's always great to see AI tutorials, but I don't like it being here in it's WIP state.

I'll move it to the Members' Project forum and add a WIP prefix, if you don't mind.

Fine with me, I just wanted it somewhere I could work on it. Thanks :)

Okay, this can be of little help, You know...
I have an AoS in progress and have many assault and escape routes.

So I'd be a haapy person if you could write a few things about...
1. AI preperly choosing route of assault and escape
2. AI using Custom Spells with indicated methods
3. AI helping teammates, rather than playing for himself.
4. AI' Misc behaviour, like Last hit kills / denies, Defending base and etc. etc.

As I've stated before, this tutorial is for AI's in general, and is designed to help you get started. It is not supposed to do everything for you, it's supposed to make you think first before creating the AI, so it gets done correctly the first time.

This tutorial forget to mention 1-2 thing.

An AI should be categorize into 3 difficulty. Easy, normal and insane. A map should not contain a AI whenever any difficulty of the AI choosen, the AI are still acting the same.

This is up to the map creator, and is not important to how an AI works. What if the map creator wanted different AI *personalities*, where every AI acts differently. Difficulty is strictly a coding and map-specific concept, not a design concept.
 

Septimus

New Member
Reaction score
58
This is up to the map creator, and is not important to how an AI works. What if the map creator wanted different AI *personalities*, where every AI acts differently. Difficulty is strictly a coding and map-specific concept, not a design concept.

Yes, but the difficulty could make their personalities more agressive or not.
 

Sid

Member
Reaction score
5
If the tutorial just theorizes about what to take into account while making an AI, then I believe it can be of very little use to me.
I have already created an AoS AI, what I seek is a refinement.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top