YesNoOk
avatar

AI Coding Tutorial (Read 62980 times)

Started by Romeotantan, November 17, 2009, 12:13:32 am
Share this topic:
AI Coding Tutorial
#1  November 17, 2009, 12:13:32 am
  • ***
  • Portrait maker/AI coder
    • Egypt
    • romeotantan.webs.com/
I noticed that there isn't any AI coding tutorial here except for Winane's AI method but it does not show how to code moves for the cpu to use, So i thought to give it a shot, I'll be explaining the "Cpu only commands" activation method not Winane's method, It takes just few seconds to kick in, I know that Winane's method is better but Cpu only commands is easier to learn and much more simple.

Before i proceed, I feel obligated to say that if it wasn't for Liger i wouldn't type this tutorial, He tought me every thing i know, Ok now lets begin...

First off, Open the CMD file of the character and add lines like these to declare the AI only commands and above any thing else in the CMD file:

Code:
;-| AI |------------------------------------------------------
[Command]
name = "CPU1" <------------------------(AI Command Name)
command = U, D, F, U, D, F <------------(Command combination)
time = 0

[Command]
name = "CPU2"
command = U, B, F, U, D, F
time = 0

[Command]
name = "CPU3"
command = U, D, D, U, D, F
time = 0

[Command]
name = "CPU4"
command = U, F, U, B, U, D, F
time = 0

[Command]
name = "CPU5"
command = B, B, B, U, B, U, D, F
time = 0

[Command]
name = "CPU6"
command = U, D, B, U, B, U, D, F
time = 0

[Command]
name = "CPU7"
command = F, F, B, U, B, U, D, F
time = 0

[Command]
name = "CPU8"
command = U, D, U, U, B, U, D, F
time = 0

[Command]
name = "CPU9"
command = F, B, B, U, B, U, D, F
time = 0

[Command]
name = "CPU10"
command = F, F, B, B, U, B, U, D, F
time = 0

You can add as much more as you like but don't exceed 60 cause the CMD only supports 128 unique commands per character including human commands, And you will not need that much any way, I only use 40 or even less, Also don't use same command combination, Each cpu command must have a unique combination and it doesn't matter what the combination is as you see above it's just some random combinations.

It's time to announce to the CPU that it has control over the character, You can add the activation code in the CMD file under [Statedef -1] preferbly at the end of the CMD, Or you can program the AI in one of the CNS files of the character under [Statedef -2] or under [Statedef -3] but those statedefs must be declared, in some characters -2 or -3 are not declared so you have to declare them yourself by typing [Statedef -2] or [Statedef -3] and then add the activation code under them, in the CMD [Statedef -1] is always declared by the creator so no need to declare it again but if you separate the AI from the character files in a separate file, You're gonna have to declare it again.

Activation Code:
Code:
; AI switch -> ON
[State -1, Activate AI]
type = Varset
triggerall = var(59) != 1
trigger1 = command = "CPU1"
trigger2 = command = "CPU2"
trigger3 = command = "CPU3"
trigger4 = command = "CPU4"
trigger5 = command = "CPU5"
trigger6 = command = "CPU6"
trigger7 = command = "CPU7"
trigger8 = command = "CPU8"
trigger9 = command = "CPU9"
trigger10 = command = "CPU10"
v = 59
value = 1

This is a variable set telling the computer that when Var(59) is = 1 then do this and do that, But you must make sure that the variable 59 is available and not used in any thing else in the character coding or else use another variable, Also you must copy and past this line "triggerall = var(59) != 1"in each and every human command in the CMD file to differ between the commands you use to play with the character and the commands the CPU use against you, You'll find in the character CMD file human only commands look like this:

Code:
[State -1,FLK]
type = ChangeState
value = 310
triggerall = command != "holddown"
triggerall = statetype = S && ctrl
trigger1 = command = "a" && command = "holdfwd"
trigger2 = command = "a" && command = "holdback"

Add the AI cancelation code to it like this:

Code:
[State -1,FLK]
type = ChangeState
value = 310
triggerall = var(59) != 1 <---------------- This cancels the AI usage of the human commands
triggerall = command != "holddown"
triggerall = statetype = S && ctrl
trigger1 = command = "a" && command = "holdfwd"
trigger2 = command = "a" && command = "holdback"

It's a lot of copy and paste but that way you'll cancel any interferance from the default Mugen AI, Now the character is like a blank page for you to write what you see fit, But before we venture into AI programing, Open the CNS file and in the [Data] paragraph change the number of the IntPersistIndex to = 58, if it's already = 58 then keep it and if this line is not typed, Type it yourself "IntPersistIndex = 58" don't ask why cause i realy don't know, it just activates the AI faster i think.
Edit: This means if you activated the AI in round one, it'll still be active in round 2+. (Thanks Cyanide)

Edit: Please note that the programing of the AI itself i'm about to explain doesn't matter if you use this activation method or Winane's method, It's the way AI is programed in both.

Now you start programing the AI, Each cpu command must have [state -1] declaration or -2 or -3 depending on the state you're programming the AI in, For example:

Code:
[State -1, AI] ; punch
type = ChangeState
value = 200 <----------------------- State no. of the animation you want the CPU to perform
triggerall = roundstate = 2 <--------- Trigger during the fighting phase of the round "Round One...Fight"
triggerall = var(59) = 1 <------------ AI variable that must be used in every CPU command
trigger1 = ctrl = 1 <----------------- Character can be controled (Not performing a move)

Now you told the CPU that when Var(59) equals 1 and you have control over the character then perform a change state, In this case the state wanted is a weak punch(value = 200), There are 2 ways to know the state no. of the character moves while coding the AI, First one is choosing the character in training mode and turn on debug mode by pressing ctrl+D, Performing every move and the debug mode will tell you the state no. of the moves, The second way is the easiest just open the character in fighter factory and press the animation tab, you'll find the begin action no. bar displays every move state no.

But the code above is very basic and will make the character keep punching continuasly like an idiot, So you must add more triggers to make the character punch only in a certain situation like this:

Code:
[State -1, AI] ; punch
type = ChangeState
value = 200 <----------------------- State no. of the animation you want the CPU to perform
triggerall = roundstate = 2 <--------- Trigger during the fighting phase of the round "Round One...Fight"
triggerall = var(59) = 1 <------------ AI variable that must be used in every CPU command
triggerall = statetype != A <--------- Trigger when the char is not in air
triggerall = random < 500 <---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
triggerall = p2statetype != L <------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist x = [0,40] <--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
triggerall = p2statetype != A <------- Trigger when the opponent is not in air
trigger1 = ctrl = 1 <----------------- Character can be controled (Not performing a move)

Now you told the CPU that when Var(59) is equal 1, The char is not jumping, Opponent is not jumping, Opponent is close, Opponent is not lying down and char is controlable then perform a weak punch, Now the code is much smarter.

The differance between triggerall and trigger1 is:
Triggerall is a condition that must be met for the whole changestate to be performed but trigger1 is a condition that triggers one part of the changestate, You can have trigger2, trigger3 or more like this:

Code:
[State -1, AI] ; punch
type = ChangeState
value = 200 <----------------------- State no. of the animation you want the CPU to perform
triggerall = roundstate = 2 <--------- Trigger during the fighting phase of the round "Round One...Fight"
triggerall = var(59) = 1 <--------------- AI variable that must be used in every CPU command
triggerall = statetype != A <------------ Trigger when the char is not in air
triggerall = random < 500 <------------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
trigger1 = p2statetype != L <----------- Trigger when opponent is not lying on the floor
trigger1 = p2bodydist x = [0,40] <------- Trigger when the opponent is between 0 to 40 pixels away horizontaly
trigger1 = p2statetype != A <----------- Trigger when the opponent is not in air
trigger1 = ctrl = 1 <-------------------- Character can be controled (Not performing a move)
trigger2 = stateno = 210 && movehit<--- Trigger it in a combo when in stateno. 210 and the move hit the opponent
trigger3 = stateno = 400 && animtime = 0<--chain it to stateno. 400 and the animation is over

You can see that trigger1 is a different condition than trigger2 and trigger3, Three different conditions that the changestate can be performed in but all must meet the triggerall condition to be performed.

Now how to chain moves to each other, as you can see in the code above there is "trigger2 = stateno = 210 && movehit" means that trigger the weak punch after the low punch (210) is performed and did hit the opponent, There is also "movecontact" meaning that the move made contact whether it's a hit or got blocked.

Ok it's past midnight here and i have to sleep to go to work cause i look like this  :beadyeyes2: so i'll continue tommorow and add a list of triggers and thier discreption to complete the tutorial and start answering your questions and/or curses.
Last Edit: November 17, 2009, 06:02:24 pm by Romeotantan
Re: AI Coding Tutorial
#2  November 17, 2009, 12:29:35 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Quote
IntPersistIndex = 58
don't ask why cause i realy don't know, it just activates the AI faster i think.
That means if you activated in round one, it'll still be active in round 2+. Also, you could at least know what intpersistindex does and how it works if you're going to tell people to use it. If they have var(30) using this won't do anything at all as it's numbers above that value. var(30) would reset with intpersistindex = 58.

Also, you should point out that random is evaluated every tick. And evaluated differently for every instance that it's called. Random > 500 is only 50% if evaluated on a single tick. Taken over 2 ticks the probability of it activating is 100%. It's very strongly recommended that random is kept below 100. You should only go above that for guaranteed follow ups or moves you wish to occur a lot.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: AI Coding Tutorial
#3  November 17, 2009, 04:39:44 pm
  • ***
  • Portrait maker/AI coder
    • Egypt
    • romeotantan.webs.com/
Please do explain more about the intpersistindex Cyanide, If they use Var(30) what's the no. to use in the intpersistindex? Would it be 30 as well or 29? I don't realy understand it.

I must continue explaining how chain combos work cause i explained it in a rush, We used the weak punch in our first AI move and we want to chain a weak kick to it, Then we use the weak punch as a trigger for the next move like this:

Code:
[State -1, AI] ;weak kick 
type = ChangeState
value = 210
triggerall = roundstate = 2
triggerall = var(59) = 1
triggerall = statetype != A
triggerall = p2bodydist x < 45 <---------------- Opponent is still close after recieving the punch
triggerall = p2statetype != L
trigger1 = stateno = 200 && movecontact <---- Trigger when in state no.200 and the move made contact

So the AI will always use the weak kick(state 210) after the weak punch(state 200), if you plan to program different moves after the weak punch then you must add a random trigger for both AIs like this:

Code:
[State -1, AI] ;weak kick 
type = ChangeState
value = 210
triggerall = roundstate = 2
triggerall = var(59) = 1
triggerall = statetype != A
triggerall = p2bodydist x < 45
triggerall = random < 200 <------------------- lower nomber cause the AI will check this first
triggerall = p2statetype != L
trigger1 = stateno = 400 && movecontact

[State -1, AI] ;strong punch
type = ChangeState
value = 220
triggerall = roundstate = 2
triggerall = var(59) = 1
triggerall = statetype != A
triggerall = p2bodydist x < 45
triggerall = random < 300 <------------------- slightly higher number
triggerall = p2statetype != L
trigger1 = stateno = 400 && movecontact

Keep in mind that the AI checks the CPU commands In order from top to bottom, So in the code above the AI will check the weak kick first then checks the strong punch, That's why if you want a 50% between them use a higher number for the random trigger in the second one(Trial and error for best results), Also if you want to chain special or super moves you better use "movehit" to ensure that the opponent is open for that kind of move cause using only "movecontact" may result in your character being open after the opponent blocked the first move (but it's your own preferance) Also if you want to code super or dream cancels you have to use "animtime" like this:

Code:
[state -1, AI] ;Haoshikoken Weak
type = changestate
value = 3000
triggerall = roundstate = 2
triggerall = var(59) = 1
triggerall = statetype != A
triggerall = power >= 1000 <---------------------------------Trigger when char have one power stock
triggerall = movetype != H <---------------------------------You can't attack when you are being hit
trigger1 = stateno = 1400 && movehit && animtime = 0<------Trigger when in state 1400 & the move hit the opponent & the move just ended.

[state -1, AI] ;Reyuko ranbu
type = changestate
value = 2100
triggerall = var(59) = 1
triggerall = statetype != A
triggerall = power >= 1000
trigger1 = stateno = 1300 && movehit && animtime = -25 <----Trigger when in state 1300 & the move hit the opponent & there are 25 more ticks left in the animation.

Animetime is used for certain situations were you can super or dream cancel in, so you have to check those first in your character, but "animetime" could be used for normal and special moves too, also if you plan to make AI that is not cheap you might want to use the same triggers the Human only commands use to make sure the AI is like a very smart and quick human fighting you and not doing impossible moves like uppercuting while being hit or something like that(but this comes with experiance anyway)

As for the list of the most common triggers used in AI coding:

triggerall = roundstate = 2 <--------- Trigger during the fighting phase of the round "Round One...Fight" as you don't want your character to attack the opponent before the round start(or do you?)
triggerall = statetype = A <------------- Trigger when your char is in air(any trigger can have it's opposet by typing "!" next to the equal like the next one)
triggerall = statetype != A <-------------- Trigger when your char is not in air
triggerall = statetype = S <--------------- Trigger when your char is standing
triggerall = statetype = C <--------------- Trigger when your char is crouching
triggerall = statetype != L <--------------- Trigger when your char is not on the floor
triggerall = p2statetype = A <------------- Trigger when your opponent is in air(uppercuts dear friend)
triggerall = p2statetype != A <------------ Trigger when your opponent is not in air(this includes rolling back & forth)
triggerall = p2statetype != L <------------ Trigger when your opponent is not on the floor
triggerall = p2statetype = S <------------ Trigger when your opponent is standing(mainly for throwing ability)
triggerall = p2statetype = C <------------ Trigger when your opponent is crouching
triggerall = movetype != H <-------------- Trigger when your char is not being hit(anti cheap of course)
triggerall = movetype = A <--------------- Trigger when your char is in an attack state
triggerall = p2movetype = A <------------- Trigger when your opponent is attacking(good for counters)
triggerall = p2movetype != A <------------- Trigger when your opponent is not attacking
triggerall = p2movetype = H <------------- Trigger when your opponent is being hit(good for combos)
triggerall = p2bodydist x >= 150 <--------- Trigger when your opponent is more than 150 pixels away horizontaly(far)
triggerall = p2bodydist x <= 30 <---------- Trigger when opponent is less than 30 pixels away horizontaly(close)
triggerall = p2bodydist x = [30,80] <------- Trigger when opponent is between 30 to 80 pixels horizontaly
triggerall = p2bodydist x >= 0 <------------ Trigger when opponent is in front of your character
triggerall = p2bodydist y > 60 <------------ Trigger when opponent is 60 pixels under you(good for aerial attacks)
triggerall = p2bodydist y > -60 <------------ Trigger when opponent is more than 60 pixels above you
trigger1 = ctrl = 1 <------------------------ Trigger when your character can be controled
trigger1 = ctrl = 0 <------------------------ Trigger when your character cannot be controled(good for combos)
triggerall = random < 500 < ---------------- Randomize the move
trigger1 = stateno = 700 && movecontact<-- Trigger when in state 700 and move made contact whether hit or blocked
trigger1 = stateno = 700 && movehit <------ Trigger when in state 700 and the move hit
trigger1 = stateno = 700 && movehit && animtime = 0 <-same as above but trigger after the move animation ends
trigger1 = stateno = 700 && movehit && animtime = -25 <-same as above but there are 25 more ticks left in the animation
triggerall = power >= 1000 <----------------- Trigger when you have one or more than one power stock
triggerall = backedgedist < 5 <--------------- Trigger when your character is cornered
triggerall = life < 250 <---------------------- Trigger when you have less than 1/4 of your health
triggerall = p2life > 500 <-------------------- Trigger when opponent have more than 1/2 of his health
triggerall = enemy,NumProj = 0 <------------- Trigger when there is no projectile attack from opponent
triggerall = enemy,NumProj = 1 <------------- Trigger when opponent has fired a projectile
triggerall = p2stateno = 700 <--------------- Trigger when opponent is in state no.700(use wisely)

Ok now i guess i'm finished, So if any one have questions about any thing please go ahead, And if someone has any amendments please do tell me...
Last Edit: November 17, 2009, 06:22:57 pm by Romeotantan
Re: AI Coding Tutorial
#4  November 18, 2009, 04:36:55 pm
  • ******
  • Just a butcher on a mission.
    • www.justnopoint.com/lbends
Using random with numbers higher than 100 run the risk of being robotic and predictable.  (Effectively making the random trigger pointless)
And not only that, but using random over and over again makes it very likely that some actions will take place within one or two frames of the conditions being met, since the random function has a preference of choosing lower numbers over higher ones.  (Fixed in Mugen RCx)
Re: AI Coding Tutorial
#5  November 18, 2009, 05:40:04 pm
  • ******
  • [E]
    • Mexico
that's why I normally use %100 instead of just random.
Re: AI Coding Tutorial
#6  November 18, 2009, 08:43:43 pm
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Intpersistindex is explained inside KFM.cns. Something i hope you've opened at least once. Variables above the number defined will not be reset by state 5900. That's not their value either. That's the variable number itself.

It's also why AI is better at var(59) (in old mugen at least) as it means you can comfortably leave the rest of your variables out. If you use var(0) you have to have intpersistindex on 0 (or is it -1 in that situation) and you wind up having nothing reset, which can make for lots of workarounds.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: AI Coding Tutorial
#7  November 18, 2009, 09:09:53 pm
  • ***
  • Portrait maker/AI coder
    • Egypt
    • romeotantan.webs.com/
Thanks cyanide, i now understand how it works.
@ Insanius: may be you are right about using 100 or less but i try to work my way around by randomizing all moves like i explained before by trial and error, takes a lot of time coding and testing but gives great results, cause if your char has a fair number of moves and combos and you code all of them, The result won't be robotic at all.
Re: AI Coding Tutorial
#8  November 18, 2009, 09:20:56 pm
  • avatar
  • ******
    • USA
Ignore this post. Just wanted to follow this thread.
Re: AI Coding Tutorial
#9  November 18, 2009, 09:26:26 pm
  • ***
  • Portrait maker/AI coder
    • Egypt
    • romeotantan.webs.com/
Do you mean ignore the tutorial or your post or what? ??? i don't understand
Re: AI Coding Tutorial
#10  November 18, 2009, 09:50:48 pm
  • ******
  • Just a butcher on a mission.
    • www.justnopoint.com/lbends
He clicked the "Notify me of replies" box.
Re: AI Coding Tutorial
#11  November 18, 2009, 09:56:19 pm
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Thanks cyanide, i now understand how it works.
@ Insanius: may be you are right about using 100 or less but i try to work my way around by randomizing all moves like i explained before by trial and error, takes a lot of time coding and testing but gives great results, cause if your char has a fair number of moves and combos and you code all of them, The result won't be robotic at all.
Having random too high can guarantee a move in a specific situation though. Lets take a crappily coded AI as an example.

If i take my kirby and stand directly in front of "warners" homer simpson with it's judgespear AI (i no longer have either thankfully) homer will constantly and without fail attempt to LP me. It never hits, but cos the random is so high, he just does it over and over and over with a crouching attack (or even specials) only coming into play once every 10 seconds or so. That's shyte AI and a lower random% would have cut down how much LP kicked in and given the other moves a better chance of occuring.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: AI Coding Tutorial
#12  November 18, 2009, 10:19:41 pm
  • ***
  • Portrait maker/AI coder
    • Egypt
    • romeotantan.webs.com/
That's another way to think of it, but you know i follow the ccirocky way of coding AI, i used ccikim (owesome kim) as referance in my learning stage and he always starts his combos with CLP, CLK, Kick ground and then doing this and doing that, so i always start my combos with the same way so the randomizing part takes place after the second or third hit of the combo which makes it easier to randomize, And i think your Mukai is the same, always the weak kick when i'm near him and after i'm 30 pixels away or more he starts doing other moves.
Re: AI Coding Tutorial
#13  November 18, 2009, 10:25:30 pm
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Mukai has shit AI. I'm quite happy to admit that, it's been done badly but i couldn't be bothered making a better job of it. He was difficult as it was.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: AI Coding Tutorial
#14  November 18, 2009, 10:28:14 pm
  • ***
  • Portrait maker/AI coder
    • Egypt
    • romeotantan.webs.com/
And when did any kof boss have fair AI, are you kidding man Mukai is awesome, i love to hate fighting him
Re: AI Coding Tutorial
#15  November 25, 2010, 12:57:39 am
  • **
  • "GrayCircle will once be the greatest warrior"
    • i.imgur.com/MdGQY.gif
How do you not make the move you activate again after  you activated it
"GrayCircle will surpass ever hero one day!"

My Local Name: Fighting Toys Freak.
Re: AI Coding Tutorial
#16  December 02, 2010, 11:06:39 pm
  • ***
    • mkarmageddonmugen.myfreeforum.org/
So with all that has been said about "IntPersistIndex = 58" is ot ok to fully follow this tutorial?
Re: AI Coding Tutorial
#17  December 03, 2010, 05:31:12 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Swap to 1.0, it'll make things far easier and more reliable and you won't need intpersistindex at all.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

BC

Re: AI Coding Tutorial
#18  December 05, 2010, 01:19:23 am
  • ****
    • UK
    • www.mugenevolution.co.uk/Forum
a couple of other common triggers

triggerall = !(enemynear,hitfall) ;restricts the AI doing the move when p2 is falling from a hit. Some moves are useful thoguh on a falling opponent for juggle reasons, but you'd specifiy a certain height range p2 should be for that.

triggerall = p2stateno!=5120 ;stops AI attacking while p2 is in getup from liedown state, because in the common file the player is given some invincibility in this state so if he misses it leaves him vunerable. (unless modified)
Retired from mugen but not development
Re: AI Coding Tutorial
#19  December 18, 2010, 10:45:11 pm
  • ****
  • hecc
i tryed making an AI but all it does is just walk and jump it wont attack at all
this is what the AI i put in looks like
;-| AI |------------------------------------------------------
[Command]
name = "cpu1"
command = U, D, F
time = 1

[Command]
name = "cpu2"
command = U, B, F
time = 1

[Command]
name = "cpu3"
command = U, D, D
time = 1

[Command]
name = "cpu4"
command = F, B, U
time = 1

[Command]
name = "cpu5"
command = U, F, U, B
time = 1

[Command]
name = "cpu6"
command = U, D, B
time = 1

[Command]
name = "cpu7"
command = F, F, B
time = 1

[Command]
name = "cpu8"
command = U, D, U
time = 1

[Command]
name = "cpu9"
command = F, B, B
time = 1

[Command]
name = "cpu10"
command = F, F, B, B
time = 1

[Command]
name = "cpu11"
command = U, U, F
time = 1

[Command]
name = "cpu12"
command = U, B, B
time = 1

[Command]
name = "cpu13"
command = U, B, F, F
time = 1

[Command]
name = "cpu14"
command = U, F, B, U
time = 1

[Command]
name = "cpu15"
command = U, B, F, U
time = 1

[Command]
name = "cpu16"
command = U, B, B, B
time = 1

[Command]
name = "cpu17"
command = U, D, B, F
time = 1

[Command]
name = "cpu18"
command = U, D, B, D
time = 1

[Command]
name = "cpu19"
command = U, D, F, U
time = 1

[Command]
name = "cpu20"
command = U, D, U, B
time = 1

[Command]
name = "cpu21"
command = U, D, F, F
time = 1

[Command]
name = "cpu22"
command = F, F, F, F
time = 1

[Command]
name = "cpu23"
command = U, U, U, D
time = 1

[Command]
name = "cpu24"
command = B, B, B
time = 1

[Command]
name = "cpu25"
command = D, D, D, D
time = 1

[Command]
name = "cpu26"
command = D, D, D
time = 1

[Command]
name = "cpu27"
command = F, F, F
time = 1

[Command]
name = "cpu28"
command = U, U, U
time = 1

[Command]
name = "cpu29"
command = U, U, B, B
time = 1

[Command]
name = "cpu30"
command = D, D, F, F
time = 1





; Don't remove the following line. It's required by the CMD standard.
[Statedef -1]

[State -1, AI TRIGGER]
type = Varset
triggerall=roundstate=2
triggerall = var(59) != 1
trigger1 = command = "cpu1"
trigger2 = command = "cpu2"
trigger3 = command = "cpu3"
trigger4 = command = "cpu4"
trigger5 = command = "cpu5"
trigger6 = command = "cpu6"
trigger7 = command = "cpu7"
trigger8 = command = "cpu8"
trigger9 = command = "cpu9"
trigger10 = command = "cpu10"
trigger11 = command = "cpu11"
trigger12 = command = "cpu12"
trigger13 = command = "cpu13"
trigger14 = command = "cpu14"
trigger15 = command = "cpu15"
trigger16 = command = "cpu16"
trigger17 = command = "cpu17"
trigger18 = command = "cpu18"
trigger19 = command = "cpu19"
trigger20 = command = "cpu20"
trigger21 = command = "cpu21"
trigger22 = command = "cpu22"
trigger23 = command = "cpu23"
trigger24 = command = "cpu24"
trigger25 = command = "cpu25"
trigger26 = command = "cpu26"
trigger27 = command = "cpu27"
trigger28 = command = "cpu28"
trigger29 = command = "cpu29"
trigger30 = command = "cpu30"
v = 59
value = 1

[State -1, AI BLING]
type = ChangeState
value = 22100
triggerall = roundstate = 2
triggerall = var(59) = 1
triggerall = statetype != A ;<--------- Trigger when the char is not in air
trigger1 = random < 20 ;<---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
triggerall = p2statetype != L ;<------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist x = [0,10000000] ;<--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
triggerall = p2statetype != A ;<------- Trigger when the opponent is not in air
triggerall = command = "BLING"
trigger1 = statetype = S
triggerall=power>=1000
trigger1 = ctrl
trigger1 = ctrl = 1

[State -1, AI HYPA]
type = ChangeState
value = 34500
triggerall = var(59) = 1
triggerall = roundstate = 2
triggerall = statetype != A ;<--------- Trigger when the char is not in air
trigger1 = random < 34 ;<---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
triggerall = p2statetype = A ;<------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist y = [0,10000000] ;<--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
;triggerall = p2statetype != A ;<------- Trigger when the opponent is not in air
triggerall = command = "BA BA"
trigger1 = statetype = S
triggerall=power>=3000
trigger1 = ctrl = 1

[State -1, AI POWA]
type = ChangeState
value = 3000
triggerall = var(59) = 1
triggerall = roundstate = 2
triggerall = statetype != A ;<--------- Trigger when the char is not in air
trigger1 = random < 30 ;<---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
triggerall = p2statetype != L ;<------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist x = [0,1000000] ;<--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
triggerall = p2statetype != A ;<------- Trigger when the opponent is not in air
triggerall = command = "POWA"
;triggerall = command != "holddown"
triggerall=power>=4000
trigger1 = statetype = S
trigger1 = ctrl = 1


[State -1]
type = ChangeState
value = 241
triggerall = roundstate = 2 ;<--------- Trigger during the fighting phase of the round "Round One...Fight"
triggerall = var(59) = 1 ;<------------ AI variable that must be used in every CPU command
triggerall = statetype != A ;<--------- Trigger when the char is not in air
trigger1 = random < 50 ;<---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
triggerall = p2statetype != L ;<------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist x = [0,40] ;<--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
triggerall = p2statetype != A ;<------- Trigger when the opponent is not in air
triggerall = command = "x"
triggerall = command = "holddown"
trigger1 = statetype = C
trigger1 = ctrl = 1



[State -1]
type = ChangeState
value = 240
triggerall = roundstate = 2 ;<--------- Trigger during the fighting phase of the round "Round One...Fight"
triggerall = var(59) = 1 ;<------------ AI variable that must be used in every CPU command
triggerall = statetype != A ;<--------- Trigger when the char is not in air
trigger1 = random < 500 ;<---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
triggerall = p2statetype != L ;<------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist x = [0,40] ;<--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
triggerall = p2statetype != A ;<------- Trigger when the opponent is not in air
triggerall = command = "x"
triggerall = command = "holddown"
trigger1 = statetype = C
trigger1 = ctrl
triggerall = stateno = 241 && movehit
trigger2 = stateno = 538 && animtime = 0;<--chain it to stateno. 400 and the animation is over

[State -1]
type = ChangeState
value = 538
triggerall = var(59) = 1
triggerall = roundstate = 2
triggerall = statetype != A ;<--------- Trigger when the char is not in air
trigger1 = random < 40 ;<---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
triggerall = p2statetype != L ;<------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist x = [0,40] ;<--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
triggerall = p2statetype != A ;<------- Trigger when the opponent is not in air
triggerall = command = "y"
;triggerall = command != "holddown"
trigger1 = statetype = S
trigger1 = ctrl = 1
triggerall = stateno = 240 && movehit
trigger2 = stateno = 560 && animtime = 0;<--chain it to stateno. 400 and the animation is over

; Shadow Kick
[State -1]
type = ChangeState
value = 560
triggerall = var(59) = 1
triggerall = roundstate = 2
triggerall = statetype != A ;<--------- Trigger when the char is not in air
trigger1 = random < 40 ;<---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
triggerall = p2statetype != L ;<------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist x = [0,40] ;<--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
triggerall = p2statetype != A ;<------- Trigger when the opponent is not in air
triggerall = command = "y"
;triggerall = command != "holddown"
trigger1 = statetype = S
trigger1 = ctrl = 1
triggerall = stateno = 538 && movehit
trigger2 = stateno = 539 && animtime = 0;<--chain it to stateno. 400 and the animation is over

; Shadow Kick
[State -1]
type = ChangeState
value = 539
triggerall = var(59) = 1
triggerall = roundstate = 2
triggerall = statetype != A ;<--------- Trigger when the char is not in air
trigger1 = random < 40;<---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
triggerall = p2statetype != L ;<------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist x = [0,40] ;<--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
triggerall = p2statetype != A
triggerall = command = "y"
;triggerall = command != "holddown"
trigger1 = statetype = S
trigger1 = ctrl = 1
triggerall = stateno = 560 && movehit

;Roaming Chaos
[state -1]
type = changestate
value = 1460
triggerall = var(59) = 1
triggerall = roundstate = 2
trigger1 = statetype != A ;<--------- Trigger when the char is not in air
triggerall = random < 20 ;<---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
triggerall = p2statetype != L ;<------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist x = [0,40000000000] ;<--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
triggerall = p2statetype != A
triggerall=numproj=0
triggerall = command = "z"
trigger1 = statetype = S && (ctrl)

;charge
[state -1]
type = changestate
value = 400
triggerall = var(59) = 1
triggerall = command = "hold_s" && statetype = S
triggerall = roundstate = 2
triggerall = statetype != A ;<--------- Trigger when the char is not in air
trigger1 = random < 500 ;<---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
;triggerall = p2statetype != L ;<------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist x != [0,40] ;<--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
;triggerall = p2statetype != A
trigger1 = (ctrl)

[State -1]
type = ChangeState
value = 235
triggerall = var(59) = 1
triggerall = roundstate = 2
triggerall = statetype != A ;<--------- Trigger when the char is not in air
trigger1 = random < 25 ;<---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
triggerall = p2statetype != L ;<------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist x != [0,40] ;<--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
triggerall = p2statetype != A
triggerall = command = "a"
;triggerall = command != "holddown"
trigger1 = statetype = S
trigger1 = ctrl = 1

; Shadow Kick
[State -1]
type = ChangeState
value = 236
triggerall = var(59) = 1
triggerall = command = "b"
triggerall = roundstate = 2
triggerall = statetype != A ;<--------- Trigger when the char is not in air
trigger1 = random < 30 ;<---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
triggerall = p2statetype != L ;<------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist x != [0,40] ;<--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
triggerall = p2statetype != A
triggerall = command != "holddown"
trigger1 = statetype = S
trigger1 = ctrl = 1
trigger2 = stateno = 235 && (movecontact)
trigger3 = stateno = 237 && animtime = 0;<--chain it to stateno. 400 and the animation is over

; Shadow B Kick
[State -1]
type = ChangeState
value = 237
triggerall = var(59) = 1
triggerall = roundstate = 2
triggerall = statetype != A ;<--------- Trigger when the char is not in air
triggerall = random < 30 ;<---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
triggerall = p2statetype != L ;<------- Trigger when opponent is not lying on the floor
triggerall = p2bodydist x != [0,40] ;<--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
triggerall = p2statetype != A
triggerall = command = "c"
;triggerall = command != "holddown"
trigger1 = statetype = S
trigger1 = ctrl = 1
trigger2 = stateno = 236 && (movecontact)
youre a fucking meme. another borewood. REIWOOD. SHIP CONFIRMED.
I will force feed Dark Pit right into your ass if we ever play on wi fi.
Spoiler, click to toggle visibilty
Re: AI Coding Tutorial
#20  December 19, 2010, 12:06:34 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
This thread really SHOULD NOT be for questions. Ask them in dev help if you want them looked at.

And all your AI changestates still have a command attached to them. Remove it. And don't reply here again.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.