Free time is a plenty for me today, because it seems as if TMK and PD aren't coming online... .
Anyway, Here are my AI tutorials, you may noticed that its is "rials" and not "rial", Yep, thats right, ill make some more on different "Styles" of AI.
OK, in this tutorial, incase you don't know, SBA is Sonic Battle Arena, a game that i am involved with, i code the AI and alot of other stuff, so if i mention it, you know why.
Please note that this is my first tutorial(except for a Hello World one i did, months ago), so if i don't explain correctly, then bear with me.
C5cha7 - for teaching me the 1st style of AI in the first place.
TMK and the rest of the SBA team - For giving me a chance to use my AI skills in a project.
PSPMillionaire and Whitehawk - Their tutorials got me started in LUA
PLEASE NOTE: THE DIAGRAMS USED IN THE TUTORIALS ARE DRAFTS! FOR YOUR AI TO BE USED HOW YOU WANT IT, YOU NEED TO PLAN AND MOULD IT TO YOUR "SHAPE"! AND NOT COPY SOMEBODY ELSES, LIKE MINE!
AI Tutorial 1 - Lv: Getting Started - Plans
This isn't much of a tutorial, there isn't any use of this... Yet.
Well, your probably wondering... WTF? No AI in it? Just boring planning!
Actually this is very important, i made a mistake of not planning and not "Moulding" my SBA AI, this means that all characters are the same, and will act as if "Lost" and Confused.
This un-organisation ended up with me having to redo the AI, which is very annoying.
1st, i need you to make a Flowchart, it can be made in a graphics program like PS, Paint, Gimp and Fireworks.etc
Here's mine, its a quick draft, so i want yours to be much more complicated, this helps get more idea of what your Enemy's settings will be.
Just say, im doing a game, it has one normal enemy, and one Boss:
the Boss' AI will be more advanced than the normal enemy.
This way, you know that, more moves.etc will be available to the boss, so the boss needs a plan.
There isn't much need for a plan for every enemy you do, just your first enemy, which you can use as a mould, and bosses.etc
Now, lets get on: Here's my Chart:
NOTE: THIS IS FOR A NORMAL ENEMY, NO "PERSONALITY" HAS BEEN ADDED.
If you have a look, its is pretty simple, There are 4 main areas that the Enemy can do: Move left and Right, Attack and Jump.
All of these area's branch off to 4(except for jumping) outcomes, and these join back into the main 4 after the outcome has returned, the Branches are all connected to take Action and Do nothing, this adds more randomness to the enemy.
I want you to do you own, it doesnt have to be as big, or as small as this.
Here is some instructions to do this(for a running left and right character):
1. Make 2 Boxes at the top, Label them, Walk Left and Walk Right.
2. Branch them off, make as many outcomes that you think are right for your character, i did 2 for each.
3. Label them, in the walk Right i did, move to the edge of the screen, which tells it to turn around, type something like this in:
if x = 480 then End branch
This tells you that, if it does hit the edge, it will move back up to the main 2 (Left and right).
The second box is:
if walkright == true then
random outcome = Action/ Nothing
This tells you that, if walking right is true, then make the ai randomly choose to keep moving, or do nothing.
Do the same for the left side, but changing right to left.etc
4. Join the all the boxes, to a big box at the bottom, that says action and nothing. Every single box must be connected, telling you that, there will always be a randomised outcome of what happens.
NOTE: I'D ADVISE YOU NOT TO DO THIS FOR YOUR OWN GAME STRAIGHT AWAY! DO IT FOR A TEST PROJECT FIRST, A SIMPLE ONE LIKE, THE ENEMY RUNNING LEFT OR RIGHT ONLY. WHICH WILL BE COVERED IN THE NEXT FEW TUTORIALS!
Please do this, it is important for the next tutorials when you do, it makes it easier.
AI Tutorial 2: Detailed Plan and "AI Moulds"
Here we go, Tut no 2!
Although still not into the code yet, we are coming close, and this part is vital for multiple characters!
First, in you mind, on a peice of paper, or in a word document, do this:
AI Planning 2
Enemy 1 - Easy - AI Mould 1
Enemy 2 - Medium - AI Mould 2
Enemy 3 - Hard - AI Mould 3
This tutorial is for a Track racing game! The more difficult the enemy, the faster he can go!
Explained: We have 3 enemies, each have different difficulty's and therefore have different AI.
You can change this to how you want it, and then continue, save the document, put the paper in a easy to find place, or try to remember it.
Now, make a document(Text or .Doc) and make your mould, this is a sample:
-- This Mould is only good if you have a running/racing game!
Make this for All your moulds, changing the variables accordingly, use of this tutorial will be in the next one, so make one for your game, and make another for this style racing game.
AI Tutorial 3: Character Racing Example Using AI
This Tutorial is in a new post on the next pages.
Here is a Link: AI Tutorial No 3: Character Racing Example Using AI
AI Tutorial 4 Personilizing AI - Adding Features in co-ordination with your AI:
AI tutorials - By Vaza
Next tutorial: Unknown
Please post your comments, and maybe your charts so i can see if i you did it well, there is really no right and wrong to this.
I'll post another tutorial in a bit, most likely that the Raw code will be after the 20th.