News:

MFG's Character of the Month: October 2026 Nominations

Main Menu

AI problem!

Started by reyspriter, September 21, 2008, 11:42:31 AM

Previous topic - Next topic

reyspriter

i don´t get it how to make the AI!?
;(
can some teach me?

PLease, i need it for my FAlcon mugen char!

Rajaa Retired

Coding AI is like normally coding a character just using changestates in the -1 triggered by a variables value. you can use a winane method, which i am not completely familiar with or you could use the impossible cmd method. either way you're triggering a variable.
the changestates will be different from each other here an example

Spoiler (click to show)
[State -1, AI Stand Light Punch]
type = ChangeState
value = 200
triggerall = Var(59)=1
trigger1 = ctrl

[State -1, Stand Light Punch]
type = ChangeState
value = 200
triggerall = Var(59)!=1
triggerall = command = "x"

triggerall = command != "holddown"
triggerall = statetype!= A
trigger1 = ctrl || stateno = 21 || (stateno = 100 && animelemtime(2) > 1) || stateno = 101
The top one is triggered when the variable is equal to one which is the AI var. that specifies if AI is active, and if using the impossible cmd activates it since only default AI can do them. so the var is triggered to equal one when one of those cmds are activated. so make impossible cmds or if yo don't feel like it go to another character and copy and paste them nothing serious about that. Then the varset

is triggered by any of those cmds like so.

[State -1, AI]
type = VarSet
triggerall = var(59) != 1
triggerall = RoundState != 3
trigger1  = command = "impossible1"
var(59) = 1

so when that cmd is activated the ar equals one activating AI. (ofcourse you'll use more of those cmds for activation if using impossible cmd method, but either way i think you still need more)


now for AI to work you use the changestaes like i gave an example of before.

but the triggers are what tell AI to do you have to think of circumstances and then code, most trigers you'll be suing are p2bodydist, p2stateno. it' a thought out process you have to make, and you might need a broad connection with Mugen tigers to make a precedented AI.

hope that helped

Cheers,Rajaaboy



BC

also using this method tends to make the AI repeat the variable triggered moves alot.


be sure to use Random to reduce the amount of times the move is repeated.

here is a tipical triggerall.

triggerall = var(7)=1 && random = [300,700]   ;this move now has a 30 to 70% random chance of happening now.  variable being my AI is active on that move.

p2bodydist is important for using moves that require a distance or even they might leave you vunerable.

eg: trigger1 = p2bodydist x = [80,190]    <<< triggers the move when p2 is between 80,190 X distance from p1.

a helpful sctrl is displaytoclipboard in where you can code it to view p2's distance plus others in debug.
Accepting commissions

reyspriter

thanx guys!

1. I copied and pasted this stuff in my cmd:
Spoiler (click to show)
[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


[State -1, AI TRIGGER]
type = Varset
triggerall = RoundState = 2
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

i think it dont works! nothing happens and he fights like he was before!

Here is the attack, can you make the example for me?

; Stand Light Punch
[State -1, Attack 1 A]
type = ChangeState
value = 200
triggerall = command = "a"
triggerall = command != "holddown"
trigger1 = statetype = S
trigger1 = ctrl = 1

so, you said i must add
triggerall = Var(59)!=1?

BC

#4
they way i do it might be different to everyone else, but i make a copy of the state in .cmd.

so i have 2

; Stand Light Punch
[State -1, Attack 1 A]
type = ChangeState
value = 200
triggerall = var(59)=1  ;this is what you need to make the AI active on this particular move, notice the commands have been removed, because the AI reads the impossible commands.

think about using triggeralls, like the AI cant do this move in the air, so statetype !=A ect.

and for the triggers, use p2bodydist X, or p2 vel x ect.  read the docs folder in mugen, and read exp.txt, and triggers.txt for further stuff.


; Stand Light Punch
[State -1, Attack 1 A]
type = ChangeState
value = 200
triggerall = var(59)!=1 ; ! is a logical NOT operator, the AI will not read this anyway, because its saying use this when the AI is NOT active. so everything applies here is for human player.
triggerall = command = "a"
triggerall = command != "holddown"
trigger1 = statetype = S
trigger1 = ctrl = 1



basically your the AI's brain in a weird way...you tell the AI exactly how to act.


if you wanna give the ai a move that you dont want him to execute when in the air then you know how, as ive showed you above, think also, would i want him to do the move while getting hit,(no you wouldnt)    so think of which letter to use in the trigger or triggerall movetype = 

and you wouldnt want him to glitch and try the move when in liedown........ statetype != L


also for p2's behaviour use enemy,  or even enemynear, then after the comma use body distances or velocities or whatever you want.
Accepting commissions

reyspriter

thanx again!  :o
i´ll try it out!

BC

ok but dont just copy and paste what i did for the AI bit.....its missing triggers so it wont work.


you need to come up with your own triggers, and also a random trigger so it doesnt repeat every second.

you need to give the AI a certain condition to execute the move, so dont think of something like execute it in stand when you have control, because he will do it right at the begining and never stop, unless getting hit or not in stance.
Accepting commissions

reyspriter

yeah, i will read the trigger docs! thanx again! and you are a good friend!  ;)

Fallen_angel

Quote from: blackchaos07 on September 21, 2008, 01:02:15 PM

triggerall = var(7)=1 && random = [300,700]   ;this move now has a 30 to 70% random chance of happening now.  variable being my AI is active on that move.


not really.....the attack will have 40%  chance of happening.....random gaves a value from 0 to 999, your trigger will work when the random number is from 300 to 700.

winanes method  its better than the immpossible commands...winanes method could be found on winanes page and also in the fighter factory templates

BC

oops yes thanks for pointing that out....    40% is correct.
Accepting commissions

reyspriter

thank you so much guys!! it works!!
but i have a other problem!

how can i make combos with AI?

can i add this?
triggerall = stateno = 200
trigger1 = time >= 4


[State -1, AI Punch 02]
type = ChangeState
value = 210
triggerall = var(7) = 1
triggerall = stateno = 200
triggerall = P2movetype != H
trigger1 = P2Movetype != A
trigger1 = ctrl
trigger1 = statetype != A
trigger1 = P2BodyDist X <= 40
trigger1 = random = [0, 800]
trigger1 = time >= 4

He makes now one attack and don´t continue with the 2nd of the combo!
please help!  :S

vyn

remove p2movetype != h and trigger1 = ctrl, probably trigger1 = P2BodyDist X <= 40 too

rly need to read the trigger docs mate

reyspriter

WOOOW, thanx guys! all thinks worked and my char is finished!!!!!!!!!!!!!!!!!!
i will give credit for all of you!!!!  ;D ;D

Fallen_angel

you can have   more control of the combos if you use trigger = stateno = xxxx && movehit  <- - -so it only activates when you hit  the oponent (you could use movecontact or moveguard)